Until three years ago, Bea Kozera, who died this month at age 92, did not know she played a role in American literature.

In 1947, she had an affair with a man she met on a Greyhound bus leaving Bakersfield, Calif. He was Jack Kerouac, who would go on to write “On the Road,” a book that defined a generation rebelling against conformity.

The Beat Generation would help fuel the social upheavals of the ’60s.

She was the real-life woman behind “Terry, the Mexican girl,” a character in the novel and a pivotal part of his career.

Without their encounter, “On the Road” may not have been published. The book was rejected for six years until the Paris Review published the excerpt “The Mexican Girl” in 1955.

Kozera, known then as Bea Franco, is mentioned by name more than 20 times in Kerouac biographies. For decades, many researchers looked for her to no avail.

Writer Tim Hernandez found her with the help of his mother, Lydia, a former farmworker who lives in California’s Central Valley.

When he first knocked on the door of her Fresno home in 2010, Kozera’s daughter, Patricia Leonard, told him he must have the wrong house.

“My mother is an old woman who has lived here all her life. She doesn’t know famous writers. She’s not of that world,” Hernandez said she told him.

He returned with copies of letters in Kozera’s handwriting addressed from Bea Franco.

Kozera said she couldn’t quite remember the name of her youthful fling — John? Jack? — and that she knew nothing about a writer named Kerouac.

“But she had this glimmer in her eye. She was very coy about the whole thing,” Hernandez said.

When he handed her a photo of Kerouac, she turned her back to him and her family and said to herself, “He’s good-looking isn’t he?”

“On the Road” is most closely associated with San Francisco and Greenwich Village. It plays out against jazz clubs, poetry readings and drug use.

But for a few pages, Kerouac paints the Central Valley of the ’50s — “sullen Oakies” reeling to the music of a cowboy band, an elderly black couple picking cotton, Mexican shantytowns and a young woman who fantasizes of moving to New York City with a man not of her world.

“It’s the most heart-rending part of the book. For the first time there are consequences,” said Gerald Nicosia, author of “Memory Babe, A Critical Biography of Jack Kerouac.”

“Until then, he’s just been traveling around getting high. It’s a lark. But she has family connections. Connection to the land. If she doesn’t work in the cotton fields, her children starve. It’s real.”

Hernandez said he sought out Kozera not only because of her tie to Kerouac, but because of her own life.

“The Central Valley is very working class. People tend to think their stories aren’t worth telling. They’re too busy just working and living to see their own epic struggles,” he said. “But here’s a woman whose story opens a book that changed American culture.”

Because of her connection to Kerouac, her death from natural causes in Lakewood, Calif., on Aug. 15 was international news. Hernandez’s novel “Manana Means Heaven” based on her life will be released this month.