How do I play Hard Mode In Terraria without dying and necessary hard mode precautions

You can fight the bosses away from your npc's or just move your npc's near a comfortable spot. Although it's not a total loss as npc's respawn the next day or so.