Andrew Marantz is a staff writer for the New Yorker, and a pretty good one. He’s written a lot of perceptive stuff about the tech industry in recent years. One morning in 2016, he was in his office exploring “a particularly foul part of social media undergrowth”, when the magazine’s editor, David Remnick, came in, looked at the screen and asked: “What the hell is that?” Marantz told him to sit down and watch.

He repeated some of the Facebook searches he’d been doing, bringing up toxic memes and propaganda posts and reading out the “engagement” statistics below each one: 5,000 shares here, 15,000 “Likes” there. Then he pulled up the New Yorker’s Facebook page. A recent landmark piece got just 87 shares; Remnick’s own piece about Aretha Franklin had even fewer – 78 shares. And so on. “I get it,” said the editor. “It’s not auspicious, but where’s the story in it?” Marantz pressed on, exploring the maze of pro-Trump propaganda and viral memes. “What if I could find the people who are peddling this stuff?” he asked. “That could be a story,” Remnick replied.

He was right, and this book tells that tale. To research it, Marantz frequented some of the nastiest circles of the American “alt-right”, got to know some of the home-grown virtuosos of disinformation and disruption, embedded himself in a startup that specialises in exploiting online “virality”, and reflected on the recent history of social media and its monetisation and amplification of hate, white supremacism and disinformation. His conclusions are not reassuring for anyone who regards a functioning public sphere and accountable media power as prerequisites for democracy.

Lee Atwater, ‘the Paganini of the modern political dog-whistle’, with George Bush in 1986. Photograph: Cynthia Johnson/The LIFE Images Collection via Getty Images

Early in the book, Marantz observes that “Trump seemed to draw on pools of dark energy not previously observed within the universe of the American electorate”. This supposed invisibility rather depends on historical amnesia. The white supremacism that manifested itself in 2016 has a long history, and not just in the deep south. Marantz himself traces its antecedents back to Lee Atwater – “the Paganini of the modern political dog-whistle” – who worked for the sainted Ronald Reagan and was deputy director of his re-election campaign. Atwater popularised the “southern strategy” of coded racism aimed at white voters in the deep south that turned many of them from Democrats to Republicans. (He later joined the lobbying firm co-founded by Paul Manafort and Roger Stone, names that have become familiar again since 2016.) Reagan’s communications director was Pat Buchanan, who developed “America first” from a blueprint established by Charles Lindbergh and his fellow Nazi admirers in the 1940s. And Reagan’s campaign motto? “Let’s make America great again.”

There has always been a dark undercurrent of white supremacism in some sectors of American culture. It was kept from public view for decades by the editorial gatekeepers of the old media ecosystem. But once the internet arrived, a sophisticated online culture of conspiracy theorists, racists and other malign discontents thrived in cyberspace. But it stayed below the radar until a fully paid-up conspiracy theorist won the Republican nomination. Trump’s candidacy and campaign had the effect of “mainstreaming” that which had previously been largely hidden from view. At which point, the innocent public began to see and experience what Marantz has closely observed, namely the remarkable capabilities of extremist “edgelords” to weaponise YouTube, Twitter and Facebook for destructive purposes.

One of the most depressing things about 2016 was the apparent inability of American journalism to deal with this pollution of the public sphere. In part, this was because they were crippled by their professional standards. It’s not always possible to be even-handed and honest. “The plain fact,” writes Marantz at one point, “was that the alt-right was a racist movement full of creeps and liars. If a newspaper’s house style didn’t allow its reporters to say so, then the house style was preventing its reporters from telling the truth.” Trump’s mastery of Twitter led the news agenda every day, faithfully followed by mainstream media, like beagles following a live trail. And his use of the “fake news” metaphor was masterly: a reminder of why, as Marantz points out, Lügenpresse – “lying press” – was also a favourite epithet of Joseph Goebbels.

At the end of this absorbing and disturbing book, we are left with two awkward questions. One is whether digital technology – as controlled and deployed by a small number of unregulated tech corporations that derive their profits from monetising “user engagement” (a polite term for prioritising dis- and misinformation, lies, outrage and nonsense) – now constitutes an existential threat to liberal democracy. And if the answer to that is yes, are we going to do anything about it before it’s too late? Second, was the old media ecosystem, with its elitist gatekeepers, editorial control, political bias and other flaws, really worse than what we have acquired? Or, pace Winston Churchill on democracy, was it just the worst system apart from all the others?

• Antisocial: How Online Extremists Broke America by Andrew Marantz is published by Picador (£20). To order a copy go to guardianbookshop.com. Free UK p&p over £15