Rep. Jeff Jackson knows what it is like to feel the wrath of TikTok. The North Carolina Democrat built a following of millions on the video-sharing app with his wonky, accessible explanations of legislation. But when he took to the platform to say he supported a bill that could lead to a ban of the app, the blowback was so intense that he deleted the post and apologized.

“I did not handle this well from top to bottom,” the lawmaker said in his March 16 follow-up post, acknowledging he had been “completely roasted” for his stance. “I get it.” When a revised version of the TikTok bill came up for a vote on April 20, Jackson was nowhere to be found. (His office blamed a schedule conflict for the missed vote and said Jackson, who declined to be interviewed, still supported the measure.)

Now that President Biden has signed the TikTok legislation —which eventually would ban the app unless its U.S. operations are sold—the question is whether he or other politicians will face similar blowback in November. The move has led to an outpouring of anger on the platform, where as many as one-third of voters under 30 get their news. Though the legislation is popular overall, some Democrats fear—and Republicans hope—that the law could damage Biden because the minority opposing it is passionate and overlaps with a critical part of his base.

Biden administration officials and some experts say the Chinese-controlled social-media app with 170 million U.S. users threatens national security because it can gather data on users and control the videos they see through its algorithm. The social network has said it isn’t a threat and would refuse any requests to share U.S. users’ data with the Chinese government. A TikTok spokeswoman declined to comment.

Biden’s expected opponent in November is among those predicting the president will pay a price with young voters, a group whose lagging enthusiasm is already a source of concern for the campaign. Biden “is responsible for banning TikTok,” former President Donald Trump wrote on Truth Social shortly before the bill-signing. “Young people, and lots of others, must remember this on November 5th, ELECTION DAY, when they vote!”

As president, Trump signed an executive order to ban TikTok in 2020, but it was blocked in court. He reversed his stance during the current campaign after meeting with billionaire Jeff Yass, a TikTok shareholder who has contributed nearly $50 million to Republican-aligned political groups in the current election cycle. Unlike the Biden campaign, the Trump campaign isn’t on TikTok. But a super PAC backing Trump joined TikTok on Wednesday, with videos attacking Biden and third-party candidate Robert F. Kennedy Jr.

There are reasons to doubt that the TikTok legislation will hurt Biden politically. The bill had broad bipartisan support, passing the House by a 360-58 margin and the Senate 79-18, meaning both Republicans and Democrats were responsible for its passage. It won’t take effect until after the election, if at all: The app would only be outlawed if the company’s Chinese owner, ByteDance, doesn’t sell it by Jan. 19, 2025, a deadline the president could extend by 90 days. ByteDance has vowed not to sell its U.S. operations and this week filed a federal lawsuit aimed at stopping the legislation.

Polling is mixed on how voters, including young voters, see the measure. An Ipsos poll conducted for Reuters in late April found half of Americans supported banning the app and 32% opposed the idea, with opposition rising to 50% of those under 35. In a poll conducted in March by the Democratic strategy group Blueprint, 56% of voters supported “pushing to ban or restrict TikTok, which is currently owned by a Chinese firm, unless it is sold to an American company,” including 46% of those under 45. The proposal was opposed by 27% of all voters and 38% of younger voters.

News of the potential ban has nonetheless rippled through the platform, where the bulk of political posts tend to be skeptical of Biden and Democrats, whose electoral coalition is disproportionately dependent on younger voters. In 2020, Biden won 61% of voters under 30 and 55% between 30 and 44, while Trump won over-45 voters, according to the AP VoteCast survey of the electorate. A recent Harvard Institute of Politics poll of Americans under 30 found Biden holding a more than 20-point lead over Trump—but that less than half planned to vote this year.

Biden has courted TikTok personalities, inviting them to the White House and campaign fundraisers. His campaign joined TikTok earlier this year to reach young voters, but its following remains small, and responses to its posts often fill up with angry reactions. On a recent campaign post about abortion rights, the most-liked comment was “So Biden restricting TikTok is freedom?”

The Biden campaign’s use of an app that the Biden administration considers dangerous to American interests has drawn charges of hypocrisy; the campaign contends it is legally meeting voters where they are and takes security precautions. Mia Ehrenberg, a spokeswoman for the Biden campaign, said it was “unserious, inaccurate and insulting” to claim that young voters would base their election choices on a social-media app. “Election after election, young people continue to show us they understand the stakes of this moment, and will vote like their futures depend on it—because they do,” she said.

The TikTok bill might not have the power to tip the election, but it is fair to say it hasn’t made the president many friends among users of the app. One popular genre of post depicts it as absurd and insulting that policymakers found time to potentially take away one of young people’s preferred modes of self-expression while failing to solve so many other problems. “Can we stop killing the planet? No,” says a user named Dutch in a video that has been liked two million times. “Can we at least watch videos on an app of people doing fun things and learning about the world around us? No. But don’t forget, we’re listening to you!”

TikTok boosters say the anger is bound to have electoral consequences as it seeks an outlet. “I think they are underestimating what the fallout will be,” Haylee Justine, a 31-year-old ghostwriter who lives in Washington state and goes by her first and middle name, said in an interview. She posted several popular videos telling viewers to contact their members of Congress and express opposition to a ban or forced divestment of the app, including one backing a long-shot Democratic primary challenger to Sen. Maria Cantwell (D., Wash.), who supported the anti-TikTok legislation. “I’ve never seen people come together on a level like this,” Justine said.

The action against TikTok seems likely to deepen young people’s sense of alienation , pessimism and betrayal by elites, all of which present headwinds to Biden’s re-election. Political posts on the app frequently invoke conspiracy theories and antisemitic tropes. (Jackson’s commenters frequently allege he has been bought by pro-Israel American Israel Public Affairs Committee, which donated $7,900 to his 2022 campaign.) In one video, Rep. Jamaal Bowman , a left-wing Democrat from New York who vocally opposed the legislation, claimed that its passage was payback for youth activism in opposition to fossil fuels and Israel’s conduct in its war against Hamas. “They’re going after TikTok because they are going after young people,” he said in the video.

Youth anger over the TikTok measure dovetails with many young progressives’ angst about Biden’s backing of Israel in its war, said Annie Wu Henry, a 28-year-old Democratic digital communications strategist who backs Biden but sees the TikTok legislation as a mistake. She noted that the measure passed in tandem with aid for Israel , which many young people also oppose. “These two things happening at once, the TikTok ban and the Israel aid, at the same time that peaceful protests are happening on college campuses, it feels like young people are being attacked on multiple fronts,” Henry said. “It’s like, ‘You used us when we could be helpful to you, but you don’t care about our ability to use our voices or make a living.’”

The potential power of motivated TikTok users was evident when the app pushed a notification to all users in March urging them to call congressional offices to lobby against a ban. Senators’ and representatives’ offices were flooded with calls that reportedly included tearful minors and profanity-laced rants. Many lawmakers found the onslaught alarming—further evidence that the Chinese-controlled software has the power to influence public opinion in far-reaching ways. Researchers have found TikTok tends to play down issues sensitive to China. The company disputes that conclusion and says its secret algorithm doesn’t push particular viewpoints.

Proponents of the TikTok legislation have argued that it is needed to thwart the threat of Chinese disinformation. February’s annual report of the U.S. intelligence community warned that China could use online campaigns to meddle in this year’s election by sowing distrust and doubt. That followed a December intelligence assessment that Chinese-run propaganda accounts on TikTok targeted candidates from both parties during the 2022 midterms and are getting more sophisticated. “It’s not hard to imagine how a platform that facilitates so much commerce, political discourse and social debate could be covertly manipulated to serve the goals of an authoritarian regime, one with a long track record of censorship, transnational repression, and promotion of disinformation,” Sen. Mark Warner (D., Va.) told reporters last month.

It is not just China: A Brookings Institution report released last week found Russian state media also have stepped up their TikTok operations in advance of the November vote. Like an increasing number of social-media platforms, TikTok doesn’t allow researchers to access its data, making it difficult to assess its potential impact, said Bret Schafer, who studies disinformation as a senior fellow at the German Marshall Fund’s Alliance for Securing Democracy. “You’re always concerned with what you don’t know and can’t see, particularly given the reach that we know they have with an influential voting bloc,” he said.

TikTok creators gather before a press conference to voice their opposition to the “Protecting Americans from Foreign Adversary Controlled Applications Act,” pending crackdown legislation on TikTok in the House of Representatives, on Capitol Hill in Washington, U.S., March 12, 2024. REUTERS/Craig Hudson

In other words, it is possible that TikTok could affect the election just as much by continuing to exist as by potentially being banned in the future.

Write to Molly Ball at molly.ball@wsj.com and Natalie Andrews at natalie.andrews@wsj.com