When it comes to exercise, what you eat and drink beforehand matters. After all, no one wants to cut a workout short because of a food-induced cramp, or call it quits because they haven’t eaten in hours and have no energy. Torey Jones Armul, RD, a spokesperson for the Academy of Nutrition and Dietetics, notes that “the benefit to eating before a workout is that research has shown that intensity remains stronger and recovery time is shorter if you’ve been fueling for your workout properly.” Here’s how to give yourself the energy you need to perform at your best.

What to Eat Before Your Next Workout

Both the the Academy of Nutrition and Dietetics and the Mayo Clinic recommend eating carbohydrates like fruit, steel cut oatmeal, greek yogurt or whole grain bread and incorporating small amounts of protein pre-workout.

Getting carbs in before your sweat session helps fuel your muscles and power your performance, since they get broken down into glucose, your body’s primary energy source, according to research in the Journal of Applied Physiology. Another study in the Journal of Applied Physiology looked at the effects of carbohydrate consumption on nine endurance cyclists and found that carbs before a workout improved their performance. Keep in mind that the more you use your muscles (i.e. the longer your workout), the more carbs you’ll need beforehand.

And here’s why protein matters. According to the The International Society of Sports Nutrition, eating protein before a workout protein helps your body rebuild and repair muscle. Protein also helps your body produce the amino acids you need in order for your muscles to work properly, which means protein offers benefits both during and after your workout ends. (You need your muscles to recover properly so you can finish your next workout strong, too.)

Hydration is also key. You lose fluids as you sweat, and drinking water beforehand can help offset those losses. The American Heart Association recommends hydrating up to two hours before you exercise.

If you can’t get through a morning workout without coffee first, Armul notes that your caffeine fix might actually boost your physical performance. One study in the Journal of Sports Sciences found that caffeine improved subject’s performance on an 8 kilometer run. But if you’re an afternoon or evening exerciser, approach the caffeine with caution, since drinking it too late in the day could affect your sleep.

Here are a few pre-workout snack ideas to get you started:

  1. Steel cut oatmeal topped with blueberries

  2. Peanut butter and jelly sandwich on whole grain bread

  3. Greek yogurt or cottage cheese with fruit

  4. Banana with peanut butter

And Here’s When to Eat It

When you schedule your pre-workout snack, think about what’s going on in your body when you eat. As Christopher R. Mohr, PhD, RD, explained an article for the Academy of Nutrition and Dietetics, if you eat right before a workout, your energy will be divided between your muscles, which are trying to, you know, exercise, and your stomach, which is working on digesting that food you just ate. That leaves you with less energy for your workout.

To avoid that energy drain, Armul recommends eating about 2 hours before a workout. “That maximizes your effort and reduces the risk of indigestion, but you’re also maximizing glucose availability,” she said. “I would certainly say within four hours you’d want to be eating something just to make sure that the fuel is readily available.”