SAN FRANCISCO—Not everyone who spends all day, every day in the main branch of the San Francisco Public Library is down and out. Only mostly everyone.

Kathleen Lee knows this because she spends hours a day walking the six floors of the vast, sky-lit building, looking for patrons who might need real help. They are everywhere: in the carrels, amid the stacks, on the computers. Some wear all they own on their backs and all they’ve lived through on their faces. Others hide in plain sight. Lee knows this, too, since she was homeless a few years ago. So she tries to let everyone know who she is and what she does.

“I strike up a lot of conversations,” she said at the end of a recent three-hour shift.

What Lee does at the San Francisco main library is help homeless and indigent patrons fill fundamental needs–food, shelter, hygiene, medical attention, substance abuse and mental health services. She’s one of five peer counselors, all formerly homeless, who work with a full-time psychiatric social worker stationed at the library to serve its many impoverished patrons. This outreach team, one of the first in the country, is no longer a novelty. In these hard times, as social safety nets shrink, libraries have become more vital than ever as safe spaces for people with nowhere else to go. Since the San Francisco Public Library outreach program began, about four years ago, it has been inundated with requests for guidance from libraries all over the country grappling with their new role as de facto day shelters.

“I think we’ve paved the way,” said Leah Esguerra, the SFPL’s social worker, who is in demand as a speaker at library and social worker conferences. She estimates that the library has helped more than 60 patrons find permanent housing and hundreds of others find social services.

More and more, libraries are hiring social workers, nurses and other outreach workers to serve their neediest visitors, with the Sacramento, Tulsa and Salt Lake City libraries being three of the latest. (The Greensboro, N.C. library has even started serving free meals, along with talks with prominent guests, on Mondays through the winter.) More and more, libraries are also setting rules for behavior. Many are banning sleeping, lying on the floors or bathing in the bathrooms. But striking a balance between making the destitute feel welcome and the general library public feel comfortable is proving tricky.

Beyond common sense rules for behavior, some libraries are going further, banning people with blankets, or with “poor hygiene” or “offensive body odor.” In Newport Beach, Calif., an affluent city in Orange County, the City Council passed a series of regulations last July for its four library branches that include bans on sitting, sleeping or occupying furniture “in a manner that suggests lounging.” It has also banned “a lack of personal hygiene” and sleeping bags and blankets.

The Bethlehem Area Public Library, in Bethlehem, P.A. instituted over two dozen rules for patron behavior in response to an influx of homeless people who were being dropped off every morning by a church-run shelter program. The rules include prohibitions on sleeping bags, bringing in more than two bags and “offensive body odor.”

Two library systems, in Santa Cruz, Calif., and Lombard, Ill., recently debated and decided against sleeping bans, arguing that unless a patron is disturbing others with how or where they sleep, the humane thing to do is to let them be. The Iowa City, IA library debated the sleeping ban and decided it made sense.

Each library system has its own rules. The American Library Association (ALA) doesn’t dictate or keep tabs on local libraries’ policies, including policies for handling its neediest patrons. But the ALA’s core philosophy is as assiduously democratic as the inscription on the Statue of Liberty. In 1990, when national homelessness, spurred by federal budget cuts in the 1980s, was still a young crisis, the ALA created what it called the "Poor People’s Policy.” Similar to a bill of rights, the policy encouraged all libraries to “recognize their role in enabling poor people to participate fully in a democratic society by utilizing a wide variety of available resources and strategies.”

Karen Strauss, the San Francisco’s main library’s acting head librarian, said she remembers talking about hiring a social worker for its homeless patrons “at least 10 years ago.”

Of course, public libraries have always been sanctuaries for lost souls, lonely hearts clubs for the odd and the awkward, community centers for the elderly and infirm, respites from an indifferent world for those out of work and out of options. That they offer free information, entertainment and education and staffs that tend to go out of their way to be helpful are bonus attractions. For many of society’s outcasts, the library’s allure is even more basic than books. Many simply need a safe place to sit.

“It’s very crazy out there,” said Mike Alvarez, 42, who visits the library several times a week, at different times, “and it’s very sane in here.” He said he migrated to San Francisco from Stockton a year ago, but has had no luck securing work. He said he lives in a basement with several day laborers who let him crash for free as long as he leaves during the day and tries to find work.

In interviews with half a dozen regular guests at the library who identified themselves as homeless, all expressed relief and gratitude for the library’s clean, well-lighted space, and the warmth of the building and its staff. “Nobody acts like I don’t belong here,” said Roger—“just Roger”—a 38-year-old regular who described himself as “sometimes homeless, sometimes not, sometimes using (drugs), sometimes not.”

San Francisco’s main library, part of an elegant square of buildings anchored by City Hall, happens to be the local branch library for San Francisco’s poorest neighborhood. The Tenderloin district, abutting the downtown tourist district, is home to the majority of San Francisco’s social service providers and single-room-occupancy (SRO) hotels. Many of its residents live on Social Security checks and rely on the help of soup kitchens and food vouchers for survival. It has more residents with substance abuse and mental health issues than other neighborhoods, a challenge for any library.

It has long had its own “behavioral guidelines,” revised from time to time, that include no sleeping for prolonged periods and no bathing in the bathrooms. It also has security guards and metal detectors all patrons must pass to use the facilities.

The goal, said outreach worker Lee, is never to oust a patron or make them feel unwelcome. Indeed, the first thing she does when she starts her shift is hit the library’s restrooms and carrels, looking for bathers and sleepers. Gently explaining the rules gives her an "in" to introduce herself and offer help. For bathers, she can tell them, through first-hand experience, where to find free showers available in the city 24 hours a day, and the best times to go to them. For the sleepers, she might tell them about a program at a nearby church that allows homeless people to sleep in the pews during the day.

Her hard-luck story is her greatest selling point. Lee, a former house painter, lost her home in Sacramento when the economy tanked and work dried up. She and her partner moved to San Francisco in 2009 hoping the high-tech bubble would mean more opportunities, but it didn’t. They lived in their car with their dog until the car broke down. Then, for the first time, the two middle-aged women lived on the streets.

Lee, who hid a long heroin habit, changed her life when outreach workers at a bottle and can recycling center told her about a detox program at San Francisco General Hospital. Lee kicked her habit and she and her partner also received help landing a room at a Tenderloin SRO.

After two and a half years at the library, she knows many of the regulars, if only by sight. She has had her sights on two patrons who have thus far refused any assistance. One, an elderly woman, very politely declines any offers, though Lee knows she is homeless. “I’ll get to her, hopefully, one day,” she said. “But I can totally get why she just wants to spend some time here, too.”