Take the time to think
You don't have to act immediately. Sometimes it helps to take a step back and think calmly about what you have heard.
Stay in touch with the other person
If it feels like the right thing to do, you can let them know that you are there to listen. You don't have to have solutions to offer support.
Discuss what the other person wants
Ask what their preference is. Some people mainly want to tell their story, while others are looking for advice or help.
Ask for advice if you feel uncertain. If you are not sure what is the best thing to do, you can ask for advice yourself.