Singer-songwriter Sara Bareilles is back on Broadway in the musical for which she wrote the music and lyrics, “Waitress.” While she’s taking the stage at the Brooks Atkinson Theatre in New York as lead waitress Jenna, across the country the title role for the musical, which will stop in Jacksonville Tuesday through Sunday at the Times-Union Center, will be played by Christine Dwyer.

The musical is based on the 2007 film and tells the story of Jenna, who daydreams in pies with clever names as she makes real pies for Joe’s Pie Diner. When Jenna becomes pregnant by her no-good, rotten husband Earl, she tells the audience she doesn’t want no baby. Then she meets the new obstetrician in town, Dr. Pomatter, and finds herself having an affair while dreaming of winning a pie contest so she can get out of town and really start her life.

Bareilles, who wrote songs like “Brave” and “Love Song” for the pop world, had reached out to a theatrical agent about becoming an actress on Broadway when the opportunity to write the music and lyrics came up. The idea for turning “Waitress” into a musical was already in the works when Bareilles met with director Diane Paulus about it, having never seen the movie before.

Then Bareilles watched the movie. “I was really struck by this beautiful story,” Bareilles says by phone. “It was still a huge question mark for me: ‘Am I able to do this?’”

She says she tentatively said yes, adding that it was the hardest thing she has ever done.

It was exhilarating hearing someone else sing her words and music the first time, she says. “I was nervous about handing over material and wondering if I would feel covetous of people getting to sing it,” she says. “It was completely uncomplicated. ... I loved getting to see this show,” she says.

When she’s not on Broadway, she’s been known to catch one of the shows on the tour. Every place she goes is slightly different because the audience is different — what they laugh at, what doesn’t hit as well.

In this musical’s songs and in the songs on her albums, she says, “I’m very drawn to telling stories that have to do with voices that don’t often get heard. That’s important to me.”

It’s about vulnerability and an emotional breakthrough and finding strength in times when it’s difficult to find your own strength and power. “Those are the kinds of messages that mean the most to me,” she says. “I tried to make that front and center” in the music in “Waitress,” she says.

Even though Jenna’s circumstances are very different than Bareilles’, all that vulnerability is in the songs she wrote for the musical, including the first one she wrote: “She Used to be Mine.”

The song is about the girl Jenna feels like she used to be:

“She is messy, but she’s kind,

She is lonely most of the time,

She is all of this mixed up and baked in a beautiful pie,

She is gone, but she used to be mine”

“I could relate really intensely,” Bareilles says. This song was the portal. “It’s how I could find myself in these characters. She struggles with asking for help. She is feeling like she’s a mess. She can know her own strength at times. She makes bad decisions. She’s a relatable character to me.”

Now, almost six years since she tentatively said yes, “Waitress,” Bareilles says, “has changed everything about my life.”

It has given her opportunities to star as Jenna on Broadway as well as to star in the TV adaptation of “Jesus Christ Superstar.” It also changed how she works as a songwriter.

“I know that it already has shifted my perspective of collaboration,” she says. “Making a theater project is so intensely collaborative.”

Bareilles has a new album coming out in April. She worked with T Bone Burnett on it. She says she is much more open to input from other people now. “Even approaching this record, I was open-hearted and open-minded about co-writing with other people.”

Before “Waitress” she was also “more free-wheeling” with her writing schedule. Now it’s become more assignment-based and structured.

Still, sometimes songs take an hour and sometimes they take much longer.

Even though she doesn’t have a specific plan for the next musical, either as an actress or as a songwriter, she says writing musicals “is a medium I have madly fallen in love with.”

Another theater character she’s always loved is Audrey from “Little Shop of Horrors.” It used to be the role Bareilles would say she would love to play. Now she thinks she’d love to develop something new. “I don’t know what story, but I so much would love working in theater again.”