I think it's one of those things that has multiple parts to it. There are things that make online better and things that make in person better. In cases like that I tend to think a mix is good so you can get the best of both worlds.
Social media, forums etc (especially when anonymous) give more freedom to go deep without risking being treated differently, judged, having rumours spread and other nasty consequences.
It also gives more chance of connecting with people who share more similar experiences or issues. You might not know anybody in person who has suffered from abuse or a traumatic event etc, but somebody online may have and it can be very beneficial to know you aren't alone and to share thoughts with people who can get them that little bit better than others might. Sometimes sympathy is no match for genuine understanding.
And it can be more accessible to some people who perhaps have limitations in the real world be that anxieties or mental limitations, physical limitations, just not really having anybody to talk to or whatever else.
The online world is available 24/7 too. If you are having a sleepless night with horrible thoughts filling your head you may not be able to call on a friend, but the Internet will be there and there even a decent chance somebody is able to talk too (or you can at least get your thoughts out and "talk to somebody" without your friend waking up to 17 texts and worrying about you the next day).
With in person communication you have the advantage of being able to see somebody listening to you, being able to get physical comforts like a hug, potentially having somebody physically get you out of your dark space for a little while (sunlight, fresh air and a change of scenery are good for mental health on at least some level). Talking to people who are an actual part of your life also means they can potentially make steps to support you like coming to check on you, going for walks with you, collecting prescriptions or food, going with you to doctors appointments etc.
For me personally online support was a big part of my journey. I was able to bounce my thoughts there and get advice when I wasn't sure about myself yet to bring things into the "real world" and when some of my real world friends weren't as supportive as I perhaps needed (not everybody is able to offer that kind of support and that's fine). It's the words of strangers online that led to me making my first doctors appointment and helped me to work through some of my thoughts and feelings enough to convey them to my doctors.
From there the majority of my recovery came from real world support (a good friend, therapy, medication and life changes), but it's the online world that paved the way for all of that.
Both online and real world interactions have their part to play in a persons mental health journey and in some respects those roles are quite different. I don't really think that one is better or worse- it depends on what that person needs and is gaining from each.
And of course both do also have potential negatives too.
People on the Internet can sometimes be more cruel because they are distanced from the situation, they can be unable to react to concerns as they might be able to in real life, it can lead to warped thought processes and ideas, people can sometimes sensationalise or make light of mental health and other issues online etc etc. A lot of those potential issues are ones that you could also face in the real world, but that are often more prevalent online due to a larger community (so you're just more likely to come across an ass hat) and the distance it gives (less consequences and/ or empathy and guilt).
Things are also in a lot of ways less private online. For the most part anybody can see what you post online and sometimes you may not be as anonymous as you imagine. That can mean you say things you believe are private which end up anything but. And unfortunately the Internet tends not to be the best at forgiving or forgetting.
On the flip side though people in real life can also be cruel and in real life you can't just switch to a new profile. There may also be specific people in the real world who you want to avoid knowing certain things for various reasons.
Really there is no black and white with this. Both can be good and bad. A lot of it depends on the individual and their situation but also just on luck (especially online).