It is primarily used to help people with insomnia, particularly those who have trouble falling asleep or staying asleep throughout the night. Lunesta is a prescription-only medication, so a valid prescription from a healthcare provider is required to purchase it online.