Book lovers say it's nothing to keep quiet about: San Francisco's libraries are thriving.

In the past six years, nearly two dozen new and renovated branch libraries throughout the city have opened their doors. With three more to go, the largest capital improvement project in the library's history is coming to an end. And a happy ending seems sure: Checked-out materials and visits, already in the millions, are on the rise.

Elsewhere, shrinking budgets mean libraries are closing the books on better days. All 18 of San Jose's branches are in danger of closing. Oakland considered shuttering 14 libraries this summer. Santa Clara County now offers library cards to nonresidents - for $80.

But San Francisco's libraries are doing well for a number of reasons, including their widespread presence in community life and a fundraising arm that can both generate money and lobby for the city agency.

"We like to think of it as a rebirth or a renaissance," said City Librarian Luis Herrera.

On the surface, having healthy libraries in San Francisco seem like a given. The city gave rise to such literary giants as Jack Kerouac and Mark Twain. Its population is generally affluent and well educated. But there was a time when libraries languished.

Following the 1980s recession, when the library's budget fluctuated yearly, some branches were open just two days a week. Others lacked professional librarians and new books.

San Franciscans then voted to give the library a set percentage of the city's general fund for 15 years, first in 1994 and again in 2007. The steady source of money helped increase hours and books, but several buildings remained inaccessible to the disabled, susceptible to quake damage or simply too cramped to accommodate demand.

That led to voters' approval of the Branch Library Improvement Program in 2000 to remodel or replace 24 branches for $106 million.

Library officials say their success stems from each branch's intertwined relationship with its neighborhood.

LGBT literature is on hand at the Eureka Valley/Harvey Milk Memorial Branch Library, renovated two years ago. The Western Addition branch, renovated in 2008, acknowledges the Fillmore and Japantown districts with books about African American and Japanese culture.

"There are little communities that pop up at every branch and reflect the character of the neighborhood," said Jill Bourne, deputy city librarian.

That sense of ownership manifests in the Council of Neighborhood Libraries - a group of volunteers from each branch who meet monthly with staff - and the construction process. The Visitacion Valley and Ortega buildings, for instance, got program rooms in part because local groups wanted a place to meet.

Not every project has gone smoothly. Two neighborhood groups are suing over the renovation of the North Beach library.

But if voters hadn't approved the capital improvements, facilities that were seismically unsafe would have had to close, Herrera said.

"We'd probably have one of the worst urban libraries in the country, because those buildings, it was not pretty," he said.

The budget challenge

The recession has hit libraries hard nationwide, said Marcia Warner, president of the Public Library Association. While voters generally back library bond measures, shrinking budgets make libraries "easy targets," she said.

"If I have to choose between taking police and fire down or taking libraries down, on the surface of it, it seems like, 'Oh, no big deal, we have to have these safety things,' " Warner said. "But then you begin to realize that libraries are at the core of a city's or a community's education."

The damage is not absolute. Martinez renovated its library this summer. Walnut Creek opened a $40 million library last year. Berkeley's four branch libraries are scheduled for $26 million worth of upgrades.

But elsewhere, from Indiana to Washington, D.C., libraries are cutting back. A private company, Library Systems & Services, has taken over public libraries in California, Oregon, Tennessee, Kansas and Texas.

In San Jose, budget cuts have forced branches to operate four days a week with a reduced staff and all branches except the main library may close.

"For a city of 947,000 people, one point of access in one part of town isn't going to meet their needs very well," said Jane Light, the city's library director.

The difference in situations boils down to dollars, she said: "They (San Franciscans) have different kinds of revenue streams, a tremendous stream of tourists, visitors, lots of sales taxes."

To supplement city funds, each branch in San Jose has a fundraising "friends" chapter, but the results can be uneven, Light said.

In contrast, San Francisco's system has a single fundraising arm: the Friends of the San Francisco Public Library, a group that raises money for programs and furniture and lobbies on behalf of the library, which, as a city agency, is not allowed to advocate for itself.

"I can talk to a donor and explain to them they are going to be investing in a public institution," said Donna Bero, the group's executive director. "I can talk to an elected official and let them know that in a tough economy, they help relieve the city's budget by adding value to a civic institution."

Timing also has been crucial, with the Branch Library Improvement Program launched long before the 2008 recession.

"We just did it at the right time," Herrera said.

A civic treasure

The new and renovated libraries are expected to stay in good condition for at least 40 years. If foot traffic is an indicator, the project has succeeded. Visits, circulated materials and registrations have, on average, at least doubled at buildings within six months of reopening, according to spokeswoman Michelle Jeffers.

On a recent afternoon at the Potrero branch on 20th Street, Maria Yap, 47, was reading about Japanese architecture. Before her stretched a stunning panorama of the skyline, glittering in the sun - a view unveiled by the building's $5.4 million renovation.

Yap likes what she sees.

"Libraries," she said, "are definitely something we've got to hold on to."