Many things. Look at healthy sleep guides and FOLLOW THEM, ie, no screens close to bedtime, go to sleep and wake up at same time etc. I had insomnia for about 9 months after DC was born. My main problem was waking up in the middle of the night and not going back to sleep for hours, which resulted in very bad anxiety and some depression.
Things that helped me:
A sleep dr. I am in US with excellent health insurance so I did not pay for it, but I would take out a second mortgage to pay for it if I had to for all that it helped me move past insomnia.
Dr worked out that I was spending too much time in bed so she had me restrict - she worked out I was actually sleeping roughly 8.5 hours a night, but going to bed at 8, waking up for 4 hours and then sleeping in until 8-9am. So she had me restrict my sleep hours, which was super scary at first but was very effective within a couple days.
Look up CBT for sleep - the dr I saw specialized this but it's been shown to be more effective than medication and most other treatments for long term insomnia. Changes how you think, so you wake up and think, oh, I'm just having a normal sleep cycle and go straight back, instead of entering the anxiety doom cycle of I will never sleep again.
For me, part of my long term recovery was knowing I had a really effective medication I could take (for me it's 1/4 of the lowest dose of mirtazapine as the "nuclear option", for you, maybe that's something else. The medium option to benadryl. By knowing I can just get up and take that medication, I usually don't need to. But I also know if I'm going through a rough patch, one night of mirtazapine kicks me back to a regular sleep schedule.
Melatonin had been helping me for a while, then I started having nightmares which were waking me up. Melatonin can cause nightmares so I had to stop that.
Some of what she helped with was identifying what was waking me to stop me getting back in the cycle. Things I didn't know: caffeine has a half life of 14 hours. So now my coffee cut off is 9am. Carbonated beverages irritate your bladder and can make you feel like you have to pee more. I have chronic pain in my hip, it's not enough to stop me doing anything, but it was waking me up. So I have to do my physical therapy regularly and I take more ibuprofen than I should if it's at all painful.
When I was in crisis, I was prescribed lorazepam, for anxiety, but you can only take it for a few days/a week because it can be addictive. I do think it helped me calm down ENOUGH to let the mental health strategies, life style changes and less intense medication work.
Longer term, exercise, good diet and generally good sleep habits have mostly kept me without insomnia. When I do have a bad patch, I have medication that stops me getting too far down a bad anxiety cycle. I have taken medication maybe 3 times in the last year.
I don't know if I could have recovered without the Dr's help, it certainly would've taken a lot longer. There are some good books and resources out there, but the dr really helped identify what my problems were and had solutions to treat them.