I find Benadryl very effective - it's OTC and there is mixed information online as to whether it's great to take it longer term, but one of the main concerns is psychological dependence, which will be true really for any medication - you'll feel like you can't go to sleep without help. So longer term, seeing a therapist for CBT is a really good solution, there are specialists who do sleep related CBT.
Other medications, really low dose antidepressants, they make you sleepier the lower the dose. I was prescribed mirtazipine and take 1/4 of the lowest adult dose. It makes me incredibly sleepy as the main side effect. It does cause weight gain long term, I crave sugar when I've taken it and literally want to eat everything in sight (I am size 8-10 and have a very healthy relationship with food generally!) but for weeks or even months, it's not likely to be a huge problem (so I was told).
If you're struggling with anxiety/difficult thoughts etc, an antidepressant may be appropriate anyway AND therapy. But also Lorazepam, it's an anti anxiety medication, also addictive and can only be taken short term but it was the only thing that was truly effective (makes you sleepy and relieves anxiety) when I was having an insomnia crisis post baby. If you're bereaved, you may benefit from something to help with the root cause, rather than just being knocked out. I think you can take it for a couple weeks without it being an issue. I also found my anxiety sort of slide right off my brain, like I couldn't really ruminate when I took it (which was good).
I personally also get knocked right out by a cocodamol, obviously also shouldn't take long term and I personally hate it because it makes me really nauseous but I don't do well with opiates.
For some reason I never was prescribed/offered Ambien, but that's obviously a powerful sleep medication as well.
I had a several months long crisis with insomnia after DC was born. Medication helped me sort of get over the hump until the CBT therapy could really do it's job, then over time my anxiety about sleep lessened because I was mostly sleeping ok and I was able to have some nights without medication, then more and more and eventually almost all. When I was really in crisis, I tended to alternate the medications more frequently, like a couple of nights with lorazepam where I'd sleep really well, then a benadryl couple of nights where when I was in crisis, I just slept ok, then mirtazipine for a couple nights then Lorazepam again, both to avoid taking an addictive medication for many nights and also to start to help move away from the more serious options.