You can be armed to the teeth and still find your self unarmed sometimes. Murphys law.
My first line of defense is heavy fire grade doors and large long heavy door bolts. An armed security system that flips on every light inside and outside when it goes off after that. The better I can see the better I can assess the situation. Then I have two options depending on how the intruder reacts. Firstly I barricade myself in whatever room I'm in. If they continue to go after me I know with little doubt hes after not just stuff but ME. I Keep an ASP collapsible baton and flashlight handy. I chose collapsible batons because they're lightweight, usable in close quarters when closed and can be used to block, hold, strike and if necessary kill. I keep a Glock Model 17 in .40 S&W with a fingerprint lock as an ABSOLUTE LAST RESORT ONLY. I don't want to start a **** storm but a lot of guys not necessary here talk big about just opening fire in a home invasion scenario. If you've never tried to hit a target under stress and fear, and it will git you. Good luck. Also the risk of colateral injury is too high. What if your child panics and runs across the living room as you open up with several rounds intended for your target.
But the best 3 things I can say to do.
HIDE - Don't be a hero, hero's get shot. your stuff is replaceable, you are not.
SECURE - Get good locks and windows, get a solid locking bedroom door. Make yourself hard to get to
ESCAPE - Get as far as possible from anybody causing or intending you to cause harm. If you have a phone call 911 if not find the nearest well lit street or avenue.