On Friday, a white supremacist gunman killed 49 people and wounded at least 40 more in two mosques in central Christchurch, New Zealand.

Jacinda Ardern, New Zealand’s prime minister, said that it was “one of New Zealand’s darkest days” and condemned the shootings as a terrorist attack. Mass shootings are extremely rare in New Zealand.

The typical home for these kinds of horrific attacks is the United States, and it quickly became clear that the gunman was inspired by various aspects of the xenophobic, destructive climate in the United States as well.

In a 74-page dossier published on 8chan, an online forum known for extremist, hate-based rhetoric, the presumed gunman issued praise for President Trump as “a symbol of renewed white identity and common purpose.”

He claimed to have been influenced by anti-immigrant American media personalities and stated that he used guns with the hope of sowing discord in the United States over the Second Amendment.

Finally, he used a U.S.-based social media platform — Facebook — to livestream his gruesome attacks. After Facebook removed the footage, other people quickly uploaded and re-uploaded the video continuously onto YouTube.

It was a terrorist attack designed to be shared on social media, to spread a message of hate and to radicalize others.

New Zealand police have captured three men and one woman, and they’ve already charged the suspected shooter, a 28-year-old Australian, with murder. As of Friday afternoon, the police had chosen not to publicly identify the shooter — a wise and rare decision that puts the emphasis back on his innocent victims.

The fact that the police managed to capture the alleged shooter, and discover two explosive devices that he is said to have left behind on a vehicle, suggests that this horrific attack could have been even worse. Their swift actions appear to have prevented even more murders.

That’s a small relief on a terrible day. But the New Zealand attack should be a stern reminder to every nation — especially the United States — of the high cost of xenophobia, and our collective responsibility for stopping it.

In the U.S., this task is being made far harder due to the presence of a president who, just this week, hinted with glee at the possibility of violence against his detractors.

“I can tell you I have the support of the police, the support of the military, the support of the Bikers For Trump,” Trump told the far-right website Breitbart News. “I have the tough people, but they don’t play it tough — until they go to a certain point, and then it would be very bad, very bad.”

Because Trump has said similar things many times in the past, it’s easy to forget how dangerous and irresponsible it is to have the leader of this country issuing such rhetoric against those who disagree with him and his strident policies against immigrants and Muslims.

This week served as yet another reminder that it is unacceptable and unconscionable.

This incident should also serve as yet another wake-up call to social media platforms.

The shooter was well-versed in the cryptic, attention-seeking tics of online forums and social media posting, and he designed his attack to be easily shared across the internet.

YouTube, for example, expressed dismay over the shooter’s actions and promised to remove videos of the attack with haste, but the ease with which his attack spread across that platform was yet more evidence of how easy it is for people to become radicalized online. The failure of social media giants to make a serious, concerted effort against hate on their platforms isn’t just disappointing — increasingly, it’s deadly.

This commentary is from The Chronicle’s editorial board. We invite you to express your views in a letter to the editor. Please submit your letter via our online form: SFChronicle.com/letters.