Electrolytes are critical for normal body function. When hiking, do we get enough in our food or should we use a supplement?

On one recent hike I was feeling sluggish after a couple days. I realized that I had been a bit dehydrated and was running low on electrolytes.