You can usually treat muscle cramps with self-care measures. Your doctor can show you stretching exercises that can help you reduce your chances of getting muscle cramps. Making sure you stay well-hydrated also can help. For recurrent cramps that disturb your sleep, your doctor might prescribe a medication to relax your muscles.
Some suggest taking vitamin B complex supplements to help manage leg cramps. However, more research is needed to confirm this benefit.