The investigators will conduct a randomized, controlled trial of internet-based cognitive behavioral therapy (iCBT) vs usual care for insomnia. The target population is patients prescribed medications for insomnia who have not had a dispensation of these medications in the preceding six months. The primary outcomes is dispensed days supply over the subsequent one year. Secondary outcomes include all types of health system clinical encounters. The investigators hypothesize that the group randomized into iCBT will have less insomnia medications dispensed than usual care controls, and less clinical encounters..