How do you treat insomnia?

Depends. Depends on if the insomnia is due to stress, psychiatric disorder, a primary sleep disorder, another medical condition, medications or poor sleep hygiene. The best treatment is addressing the reasons for the insomnia. Chronic insomnia is best treated with a behavioral program called cbt. Medications are usually indicated for short term use.
Insomnia. Depending on the causes which need to be treated first. For primary insomnia with no apparent cause, sleep hygeine works fairly well.