Leg cramps at night could be caused by muscle tightness or because you're pinching a nerve or muscle while sleeping in some position.
To prevent get cramps at night try stretching your legs before bed and for some reason licking salt when you feel leg cramps coming on can actually stop the leg cramps from happening.
Although leg cramps can be painful they're usually not a sign of anything serious and usually go away on their own.
But if you experience swelling of the legs, skin changes or redness of the skin then you should see a doctor or go to urgent care because that then could be caused by something more serious.