How do water softeners work?

Hard water carries dissolved calcium and magnesium. A water softener passes it through resin beads that swap those minerals for sodium ions, and softener salt recharges the beads so the cycle can continue.