@ginger1108 I cycle long distance (50-100km / 2-4 hours) frequently and hydration and nutrition start to matter a lot more once you push hard past a couple hours.
I started taking creatine last year and I started cramping up more often if I wasn't good about water.
I honestly don't know what the right amount is, but regularly taking magnesium, and then just drinking more water than I usually do seems good enough.
I'll usually drink a litre with some gatorade powder or just eat something salty a bit before I ride and then fill up a bottle with gatorade and water as well for the ride. When I'm doing hard efforts I need about a bottle an hour, so once I finish the first bottle I'll try and find a fountain or tap and fill it up when I can.
This is obviously way more important in the summer when it's hot and I'm sweating.
In the winter I often get away without drinking much at all during the ride as long as I hydrated well before.
It's best to just stay hydrated all the time instead of trying to play catch up... if you're feeling thirsty it's already too late.