Most adults are deficient in magnesium, and insufficient amounts of magnesium in our body can cause spasms, cramps, etc. There is a lot of information about nutrition, including magnesium, here on NT, so check it out.
There are a multitude of forms available OTC for magnesium, none of which have great absorption, so my preferred method is epsom salts in a hot bath which will absorb directly into the skin. Plus, a hot bath may help you relax
If you aren't a bath person, you could try Magnesium Oil, a topical. I'm not sure it's available anymore, been awhile since we bought it, but you apply it topically- ideally to places like the bottoms of the foot to maximize absorption (lots of veins there). It's oily, but watery, so messy, just fyi.
I also like the topical because it's hard to absorb too much magnesium this way-and too much magnesium can result in diarreah which can cause all kinds of imbalances and issues on its own.
I hope this helps!