used to have these. You get them while lying there awake right? If so it was just like me.
My sports coach said water and stretch. So i drank a bit more during the day and did like 30 secs of stretching before bed.
Stretch the muscle that cramps up. For me it was my calf muscles. So stand feet together and touch your toes (or try) and sit down, one leg straight, the other bent with foot touching straight leg knee. Reach out for your toes on straight leg.
Once or twice I got them in my thighs. So stretch those out.