First, there are no specific "right words," no magic spell for mental health; just let the other person know you care in much the same way you would when others experience any other kind of significant misfortune.
"I'm sorry to hear that" 💛 "That sounds really tough" 💛 "I'm here for you" 💛 "Is there anything I can do to help?" 💛 "You can count on me" 💛 "Hang in there" 💛 "Love ya"
Almost anything expressed with compassion -- and without criticism or making light of things -- is better than avoiding contact and saying nothing at all, which is likely to make the other person feel unseen and uncared for, especially when he or she is trying to reach out.
It's most important for the person who's suffering to feel heard and supported, and mental health conditions are really managed more than solved or removed like a roadblock. Of course, it's fine to help someone brainstorm ideas such as coping strategies if that's what you're asked, but only if asked. In any case, avoid unrealistic and simplistic solutions such as "just be more positive" or "don't feel that way."
Words aren't everything. Show you care by just keeping someone company; take a walk, listen to music, or watch an uplifting show together. Offer to run an errand or help with a chore. Text funny memes or animal photos or inspiring quotes and verses. Showing instead of telling can be an especially good helping strategy if either you or the person you're helping is dealing with trauma or other anxiety that could be triggered by talking about some subjects.
Look up more information about conditions and illnesses so you can better understand and help the person you care about and not misinterpret or underestimate their symptoms or behavior. And don't fear someone just because they have a mental health condition; most people who do are not violent, contrary to lingering myth. Check out other myths and more information on the Additional Resources page.
Counseling and other treatments such as medication, yoga, mindfulness and support groups can all be valuable and sometimes essential. Be aware of key signs of suicidality (see link below). The number for the National Suicide Prevention Lifeline is 1-800-273-8255. But if you or a loved one are in immediate danger, call 911.