Just as life, for many, now takes place both online and in the physical world, so too does death. Social media has brought back the kind of public grieving often seen in ancient Greece—open performances of sadness that bring people together for communal mourning. And a new study shows that the connections made online after a loss can last for years to come.

In the study, published in the journal Nature Human Behaviour, Will Hobbs and Moira Burke looked at data from more than 15,000 Facebook networks of people who died (the profiles were de-identified), and a control group of more than 30,000 networks where no one died. They examined the period from 2011 to 2015, and all the deaths occurred between 2012 and 2013, allowing them to see how people interacted in those networks both before and after a death.

“As expected, a substantial amount of social interaction was lost with the death of a friend,” the researchers write. But the friends’ interactions with each other spiked after the person’s death—“as people support each other,” Hobbs says, or spread the news, or coordinate in advance of a funeral. (The interactions measured here were photo tags, comments, and posts on someone’s timeline.) And while the interactions quickly declined again, once they stabilized, people in the network continued to communicate with each other far more than they did before their friend died, for at least two years.

“This suggests that the connective recovery we observed wasn’t caused by technology, but may have been aided by it,” Burke, a data scientist at Facebook, told me in an email. “Sometimes close friends of a person who dies don't know each other well, so this study suggests that Facebook helps them to connect with each other and perhaps see their mutual friend through another person’s eyes, and find other people to grieve and recover with.”

Strangely, the amount of interactions added to the network, on average, was equal to the amount of interactions lost when the person died. Almost like the network of the deceased person was healing, compensating for the hole left by their loss, flesh knitting together over a wound.

“We wouldn’t think that the interactions were replacing the person who died,” clarifies Hobbs, who did this research at the University of California, San Diego, and who is now a postdoc at Northeastern University. Rather, new connections are being forged that help fill the need for the social support that is lost when a friend dies.

There’s some variation here—the youngest group, ages 18 to 25, saw the biggest sustained increases in interaction, perhaps because the social networks of young people are always rapidly changing, Hobbs suggests. Networks of older people changed less dramatically, but still enough to compensate for the loss.

Cause of death seemed to play a role as well. The effect was greater when the person died of an unintentional injury—maybe because that kind of death is so unexpected. The effect was dampened when the person committed suicide. While a suicide is also a jarring death, it may be that the stigma surrounding it kept people from connecting publicly in the same way.

The patterns also looked a little different when the deceased person’s close friends were interacting with each other, and when close friends were interacting with acquaintances. The drop off after the initial spike was steeper with acquaintances, and more gradual when both parties were close to the deceased person.

“[They’re] settling into a new structure and that probably takes some time,” Hobbs says. “I think that’s what’s going on here, they're figuring out their new roles in each others’ lives.”

Overall, though, the researchers found that the social networks rebounded notably quickly after a loss. “Recovery dynamics here… were similar to patterns seen in resilient psychological responses to grief and trauma,” they write. In the psychological literature, “resilience” refers to people’s ability to remain stable and functioning, even after experiencing the death of a loved one or another traumatic event. “That’s not to say they are thrilled, or have no lingering sadness,” George Bonanno told me in an email. Bonanno is a professor of clinical psychology at Teachers College, Columbia University, who pioneered this idea of resilience. “However, they can still move forward and function fully in their lives.”

This study suggests that people’s support networks might be resilient as well. “We didn’t see the slow change you might have expected for working through the loss and then gradually making new friends and new relationships,” Hobbs says. “We see this really quick, what looks like a more resilient response.”

Kelly Rossetto, a professor of communication at Boise State University, found in a 2015 study that Facebook serves three major functions after someone dies. It allows people to easily spread news of the death (though it also allows for the spread of misinformation); it helps preserve the person’s memory, through their profile; and it creates room for people to “establish a grief community.”

“I think each of these could be helpful in understanding how/why new connections are being made among the deceased person's friends,” Rossetto told me in an email. The new study, she says, “brings to light the ability we have to connect to others we know and don't know, especially during a time where increased support is needed.” But she wonders: “Do these connections enable adaptation or (especially if they desist over time) do they open up the possibility for compounded loss?”

Hobbs notes that to any one person who’s just experienced a loss, it might not be apparent that their online network is starting to heal. “You only see your part of the network,” he says, “and some of those effects are small, and there’s lots of people doing a small part.”