Waking up in the middle of the night is so much worse when you start checking the time
I used to wake up, look at the clock, see something like 3:17am, and immediately start doing the math.
“Okay, I have about 4 hours left.”
Then I'd try to fall asleep again… while thinking about how little time I had left.
What helped me was honestly pretty simple: I stopped checking the time.
If I wake up, I keep the room dark, leave my phone alone, and just let myself lie there without trying to force sleep.
Sometimes I fall back asleep quickly, sometimes it takes longer. But I noticed that stressing about being awake was usually making it worse.
The less I treated waking up as a problem I had to solve at 3am, the easier it became to drift off again.