Meghan Trainor, the pop star, is sitting in an empty marble bathtub, fully clothed and flanked by two of her friends. The three of them begin soulfully crooning an a cappella version of “Made You Look,” the hit single Ms. Trainor released in the fall, nailing every note for about half a minute. Then they stop, look at one another and scream with delight.

TikTok users went wild for that snippet in November, sending it past 100 million views and attracting comments like “I’m certain this is playing at the gates of heaven.” It’s now Ms. Trainor’s most popular video on the platform.

While the performance seemed informal — after all, it was filmed in a bathroom — it was an example of how Ms. Trainor managed to get TikTok down to a science in the past couple of years, reviving her music career and winning her mainstream popularity in a way she hadn’t seen since she released “All About That Bass” in 2014.

When that upbeat, doo-wop body positivity anthem — “every inch of you is perfect from the bottom to the top” — and its pastel-colored music video earwormed its way into public consciousness, Nielsen said it sold 5.8 million copies to become the 2010s highest-selling digital song by a female artist. Ms. Trainor won the Grammy for best new artist in 2016.

Now, TikTok is the engine that drives streams on Spotify and influences what’s on the radio and Billboard charts. Popularity there is currency that record labels crave — and are hungry to replicate.

Ms. Trainor now has nearly 18 million followers on TikTok, in large part thanks to “Made You Look,” which inspired a viral dance challenge shortly after it was released in October. For comparison, Taylor Swift, who uses the app sparingly, has 18.9 million and Lil Nas X, one of the platform’s breakout stars, has 29 million.

On TikTok, Ms. Trainor posts plenty of her own music videos and dances to her own songs, along with split-screen duets with smaller artists. But she has also cultivated a playful, oversharing persona, posting videos about taking adult laxatives, shaving her face before a live television performance and sex with her husband.

On a recent afternoon in Manhattan, the 29-year-old was just as candid — she described a popular video she made about anal fissures as proof that TikTok rewarded her brand of “T.M.I.” honesty — but she was also clearly strategic in her approach to the app. Ms. Trainor, seven months pregnant at the time and clad in fuzzy slippers at her agency’s office, had just come from “The Kelly Clarkson Show” where she had a gender reveal (another boy!) after hyping the announcement for weeks on TikTok. She was joined on a couch by her close friend and TikTok sherpa, Chris Olsen, a cheerful 25-year-old content creator with his own sizable following, who has been working with the singer and songwriter as a consultant since 2022 and frequently appears in her videos.

“A lot of artists go on there, and they’re like, ‘I’m getting yelled at that I don’t have enough TikToks’ and I never once have had a conversation with my label ever,” Ms. Trainor said. “I think that’s why I enjoy it so much, and why I don’t feel like it’s a job.”

TikTok has become an undeniable culture-shaper in America since the pandemic, fueling hits in music, television and movies, even as lawmakers increasingly call to ban the app because of concerns tied to its owner, the Chinese company ByteDance.

It’s used by two-thirds of 13- to 17-year-olds in the United States, according to the Pew Research Center, while TikTok says it has 150 million users overall. TikTok has heavily influenced the music industry with its huge audience and its features for users to create dances and other videos to song snippets, along with its opaque algorithm, which can take obscure songs or singles carefully planted by record labels and send them to Spotify and radio domination.

But not all artists are willing or able to lean into TikTok the way Ms. Trainor has.

“She’s still alive?”

That — or “I thought you retired!” — were the type of comments that Ms. Trainor saw under videos using her songs, or even those that featured her, when she was scrolling TikTok in 2021. People remembered her hits, but they didn’t seem to be aware of what she had been up to lately.

Heading into 2020, Ms. Trainor’s visibility had plummeted, exacerbated by health issues that included two vocal cord surgeries. She was ready to retake the spotlight with the album “Treat Myself,” which she viewed as her best work yet. But then came the pandemic and everything shut down.

“I couldn’t perform it anywhere, I couldn’t do anything with it,” she said. “Nobody heard it, nobody saw it.”

Like millions of other Americans stuck at home, she turned to TikTok, performing covers on a ukulele and partaking in dance challenges. But it wasn’t until late 2021 that she observed the phenomenon of her earlier songs suddenly going viral on the platform, randomly seized on by TikTok users as the soundtrack to their own videos — a small-scale version of the cultural moment last year when TikTok videos propelled Fleetwood Mac’s “Rumours,” released in 1977, to the top 10 of the Billboard album chart.

“I would hear things like, ‘Did you know your song has 60 million views or whatever and there are people making videos to it?’” she said. “I was like, ‘What do you mean, that song that’s seven years old, that song?’ It was like waking up on your birthday or Christmas morning.”

The first song to surge was called “Title” from her debut album, which had never been a single. Ms. Trainor posted a dance to the song and shared its unreleased music video.

She was thrilled — and so were fans who were learning she was still around, she said.

“They’d be like, ‘Wow, I used to listen to you as a kid and I thought you were gone forever,’” she recounted. “And I was like, ‘Nah, I’ve still been here.’”

Ms. Trainor got another unexpected credibility boost with younger millennials and Gen Z — people born between 1997 and 2012 — thanks to her husband, Daryl Sabara, an actor who played the character Juni Cortez in the children’s movie “Spy Kids” in 2001 and its sequels. “Every day, they’re still like, ‘You and Spy Kids!’ and I’ll say, ‘And we have a child!’” she said. The enthusiasm is boundless. (Indeed, many comments on her videos cite Juni Cortez and “Spy Kids” in all caps.)

As two other old songs by Ms. Trainor started soaring on TikTok, through no discernible effort on her part or any reason, it became clear that the popularity had another significant effect: a jump in streams on platforms like Spotify, which translated into royalties, according to Tommy Bruce, Ms. Trainor’s manager, who also manages Harry Styles.

TikTok does pay out some money to record labels, which makes its way to artists when their songs go viral. But the bigger money comes when songs are streamed hundreds of thousands of times as people want to hear more than just the snippet from the TikTok sound of the moment. That, Mr. Bruce said, can lead to hundreds of thousands of dollars in royalties, which are then split among the rights holders of the songs — for Ms. Trainor, that could include her label and other songwriters.

“Those are things we literally had nothing to do with it,” Mr. Bruce said. “It just happened, people used the song and it created the moment.” And then, he added, because Ms. Trainor was already an avid user of the platform, it was easy for her to lean into TikTok’s culture, responding to fans and reposting videos with her side-by-side reactions. Fans ate it up.

For music industry executives who crave the kind of success Ms. Trainor has had on TikTok — and who have had to put extra effort into convincing established artists from Halsey to Ed Sheeran that it’s worth posting there — that sort of serendipitous virality is hard to manufacture.

“For the preponderance of folks under the age of 30, TikTok is basically the new FM radio,” said Bill Werde, director of the Bandier music business program at Syracuse University and the author of a popular music industry newsletter. “But instead of being controlled by major labels paying major radio programmers to sort of shove certain priority songs down the throats of fans, it’s much more chaotic and disaggregated than that.”

The attention was intoxicating for Ms. Trainor after her pandemic album, so much so that when it came to writing her latest record, she thought deeply about TikTok.

“I remember thinking about how significant that was, how ‘Title’ popped off, and it made me think, ‘Oh, the people on TikTok are really loving that old school sound that I did on my first album ever,’” she said. “I thought, what if I studied ‘All About That Bass’ and studied these older songs and figured out why they were so catchy and timeless — why they work seven years later, and try to write some of those? And I think that helped a lot.”

Ms. Trainor emphasized that she didn’t write last year’s album “Takin’ It Back” solely for the platform. The new material incorporated her experience of motherhood among other life experiences. But her consideration was in line with how everyone, from aspiring musicians to major record labels, is viewing TikTok in 2023, for better or for worse.

And in Ms. Trainor’s case, it worked.

Mr. Olsen is a TikTok savant whose humorous videos during the pandemic and a recurring stunt involving coffee deliveries transformed him from a regular guy with a musical theater degree into a comedic influencer with more than 10 million followers.

He said that one night in 2021, he posted an Instagram story that went along the lines: “I’m thinking about Meghan Trainor.” She reposted it on her own Instagram, saying, “I love you, I love your content.” Now, he’s Ms. Trainor’s secret weapon.

Ms. Trainor’s close friendship with Mr. Olsen, who regularly appears in her videos like the bathtub performance, has fascinated young fans and been dissected by outlets like BuzzFeed.

Mr. Olsen has become something of a TikTok wunderkind, giving advice to a wide range of public figures including Kerry Washington and Vice President Kamala Harris. He said he consulted for two other verified TikTok celebrities. About a year ago, he said, Ms. Trainor invited him over and casually suggested that he arrive with “some TikTok ideas.”

He took the request seriously, studying trends beforehand and arriving with a list, and from there, their get-togethers became twice-monthly events, known as “content days,” where they can make 10 videos at a time.

Mr. Olsen has Ms. Trainor’s TikTok account on his phone and they share an iCloud album with video drafts, conferring on matters like emoji selection and captions before posts. He said that they could tell if a TikTok would be a hit based on views and comments within 15 minutes, which they surveil closely; both looked aghast when asked if they had TikTok notifications turned on, with Ms. Trainor remarking that “the phone would blow up in smoke.”

Record labels and marketing agencies now regularly contact TikTok dance personalities to choreograph potentially viral shimmies for new songs and then pay influencers to perform and post them.

But, Ms. Trainor and her team say they got lucky when a duo known as Brookie and Jessie happened to create a wildly popular dance for “Made You Look” that took off with Ms. Trainor herself, everyday users and celebrities like Penn Badgley. Mr. Olsen believed the TikTok presence they had created for Ms. Trainor had primed the single to take off.

“Everyone was already on Team Meghan Trainor,” he said.

The TikTok effect is apparent in the 71-second video of Steve Lacy performing his TikTok hit “Bad Habit” at a concert last year. A shaky cellphone is filming with several other phones in the frame. The impassioned fans know all the words of the verse that was used in short snippets by hundreds of thousands of people (“I wish I knew/I wish I knew you wanted me”). Then they fall quiet.

With short-form video, the experience of a song may now be more bite-sized and ephemeral, fans may be more fickle and people could be less likely to engage with entire songs and albums.

“It used to be that you’d have these one-hit wonders on the radio, you’d be able to sell a few hundred or a couple of thousand tickets based on having one hit song, and it was awkward because the fans would wait around all night for it,” Mr. Werde of Syracuse said. “Now fans are waiting around all night for one verse.”

For music purists, the pitfalls extend beyond that. They complain that artists are engineering sounds and lyrics for what might soar on TikTok. A song may not catch on at its original pace, but speed it up a bunch like Lady Gaga’s “Bloody Mary,” and TikTok might gobble it up and put it on global charts.

Ole Obermann, TikTok’s global head of music and the former chief digital officer at Warner Music Group, said that when people fell in love with a song on TikTok — “sometimes it’s within days, sometimes it’s within weeks” — it climbed the charts at other services.We have artists that sell out a 500-seat venue when they’re touring, then they have a big success on TikTok and a month later, they’re selling out a 2,000- or 3,000-seat venue.”

Last year, according to TikTok, 13 of the 14 No. 1 songs on the Billboard Hot 100 were driven by major viral trends on the platform.

Mr. Obermann said that TikTok had rewarded a wide variety of genres, from sea shanties to Nigerian pop, and elevated scores of previously unknown artists. But he acknowledged that TikTok was changing how fans engaged with new music.

“Creators are making these really fun and entertaining and viral videos, which include the music,” he said. “It’s a different way of having that moment happen when the music excites you because there’s a visual element to it.”

It has also provided a unique level of real-time feedback. “You can upload a song or a video and you’ll know very quickly whether it’s taking off and if it’s not, you might decide, OK, there are other great songs on the album — let’s try another one,” he said.

When Ms. Trainor was writing “Mother,” the most recent single from her new album, she said that she anticipated it would offer an “anthem” on #MomTok and #MomsOfTikTok, where she spent ample time herself. But she didn’t introduce the song on TikTok. Instead, she was convinced to release an exclusive preview on YouTube Shorts, the budding TikTok rival from Google that claims more than 50 billion daily views.

In March, YouTube urged users to create short videos with a hashtag for the song and the duo Brookie and Jessie came up with another dance. But algorithms are fickle and music is unpredictable. Since then, the song has been streamed only about 49 million times on Spotify compared with more than 475 million streams for “Made You Look.”

YouTube has sought to impress upon artists and record labels that its platform, unlike TikTok, will draw listeners to longer videos, including full versions of their songs, and retain them over time.

“We look at Shorts as kind of the appetizer to the meal,” said Vivien Lewit, YouTube’s global head of artists. “We want to help artists break, we want to help new songs break, but we also want to help them grow and build sustainable careers with long-term fans.”

Ms. Trainor’s view, as much as she loves TikTok, is that everyone is getting in on short-form video from Instagram to YouTube to Spotify, and she’s interested in all of it.

In 2014, when “All About That Bass” was everywhere, it was the sort of success that her manager, Mr. Bruce, called a “once-in-a-lifetime, at best, moment for any artist.”

Now, Ms. Trainor’s music is everywhere again, thriving in particular on a platform that didn’t even exist when she released that first album.

And even if “Mother” didn’t take off the way “Made You Look” did, it was received well on TikTok and had spread across the internet, she said. She doesn’t take that for granted.

“If it’s popping on TikTok, then they’re going to play it on radio,” Ms. Trainor said. “I wasn’t played on radio for a while, you know? And now I’m in the car again, leaving dinner the other night. And I hear ‘Mother’ and I freak, and I go, ‘Turn it up — that’s my song!’”