This subject came up in conversation last week and there are two main cases where I think this is worth some attention, especially for workouts that over 30-40 minutes duration or at a high intensity:
Training for a performance goal. You want to refuel to give your body the best chance to recover as well as possible from each session to be ready for the next one.
Weight/fat loss goal. Feeding your body when it’s in a depleted state is likely to help manage hunger and stop you overcompensating for the exercise than if you wait to eat later on in the day. Generally people tend to overestimate how many calories are burned through exercise. Remember you would still need to be in a calorie deficit to lose weight.
Eat within 15-30 minutes of stopping as this helps uptake of nutrients happen 2-3x faster.
The aim is to replenish glycogen stores, encourage repair and maximising muscular adaptation to training.
Include both carbohydrates and protein ideally in an easily digestable form. This doesn't have to be a protein shake, although that can be convenient, chocolate milk is a good option or oats with milk or yoghurt or a small handful of nuts and dried fruit.
(For non-dairy soya or pea milks have similar amounts of protein to cows milk vs nut milks which are very low).
Some people don’t feel hungry straight after a workout so start small and try different things to see what you enjoy.