Sodium hydroxide is generally prepared commercially by electrolysis of sodium chloride in castner Kellner cell.
at cathode : $Na + e ^{-} \xrightarrow{ Hg }Na -$ amalgum
Anode $: Cl ^{-} \longrightarrow \frac{1}{2} Cl _{2}+ e ^{-}$
The $Na$-amalgam is treated with water to give sodium hydroxide and hydrogen gas :
$2 Na$ (amalgam) $+ H _{2} O \rightarrow 2 NaOH + H _{2}+2 Hg$