BookCourt, a family-owned bookstore in Brooklyn's Cobble Hill neighborhood, has been in the same location for 34 years, longer than most residents. It's also probably longer than anyone predicted, because a few blocks down, a Barnes & Noble looms on the corner.

Inside BookCourt, however, business is bustling. Customers inquire about titles they're searching for. Kids quietly play in the children's section. "Are you hiring?" one girl asks the clerk.

"We're doing very well," says Andrew Unger, who has been an employee at the store for three years. "We don't like people coming in and saying 'Oh you guys are suffering so much,' because we're not."

BookCourt is one of thousands of independent bookstores in the U.S. that are thriving long after analysts predicted their demise. In the early 2000s, big box stores were expected to steamroll the indie bookseller, marking the end of these cozy reading corners. Indeed, for a while, it looked like this was coming to fruition. Between 2000 and 2007, more than 1,000 independent bookstores across America closed their doors.

But then, things changed. In 2011, Borders filed for bankruptcy. Barnes & Noble's attempts to jump on the e-reading bandwagon with its Nook reader have mostly flopped. Between 2009 and 2014, the retailer closed more than 60 stores and this year plans to close another 13.

Meanwhile, independent bookstores are enjoying a revival. From 2009 to 2014, the number of independent bookstores has increased by 27 percent, according to the American Booksellers Association. Sales at independent bookstores are outpacing the growth of book sales in general.

"Bookstores are here to stay," proclaimed Michele Filgate for BuzzFeed. Thad McIlroy, a publishing analyst based in Vancouver and San Francisco, calls it the indie bookstore renaissance. But what's behind the comeback? What are independent bookstores doing right, and what can other Main Street retailers, from clothing stores to coffee shops, learn from their resilience? Here, four secrets to their success.

1. They offer an experience

While independent bookstores can't compete with Amazon or big box retailers on price or selection, the truth is they don't have to. That customers keep coming back despite other available options suggests they aren't looking for a bargain. They're looking for an experience, and the more unique, the better. "Indeed, that's all that remains is the retail experience they have going in," says McIlroy.

"I definitely wanted to create an experience," says Josh Spencer, owner of The Last Bookstore, which has become a bit of a tourist destination since it opened in downtown Los Angeles in 2009. "I thought, people aren't gonna come just to buy books, because they can buy them on Amazon." Wandering around his shop is an adventure. Odd bits of architectural flair garnish the stacks. There's a tunnel made entirely of books. In one section, the bookends are all delightfully arranged by color. People walk in to indulge their curiosity, and hopefully walk out with a book.

"You see it a lot on Tumblr or Instagram," says Katie Orphan, a manager at The Last Bookstore. "We've had a really wonderful advantage in that our store is not just a place to pick up whatever book you need but it's also a place that people go for the experience of having come here. You get a unique experience with a bookstore you can't get online. That has been a really valuable part of the store for us."

Booksellers have the added benefit of dealing in goods that many people have a nostalgic craving for. "There's a resurgence of and a consciousness of having a physical book," says Unger. "People talk about books as things to have, which I don't think they did 10 years ago. I think were seeing a lot of people coming in who want to be a part of that. They want to be in a store that sells real books."

2. They curate and recommend in a human way

The well-read employee is one of the most valuable resources bookstores offer. They know the store's unique collection inside out and can help a customer find a book just for her — in a nuanced way that's very different than Amazon's machine-generated recommendations. That kind of human-customized shopping experience is hard to find, and creates loyal customers. "You cannot invent an algorithm that is as good at recommending books as a good bookseller," John Green, author of The Fault in Our Stars, toldBuzzFeed. "And that's the secret weapon of the bookstore — is that no algorithm will ever understand readers the way that other readers can understand readers."

Unger says a good bookseller knows when to tell someone they shouldn't buy a particular book because it isn't right for them. "If they want somebody who knows books and has a relationship to whatever book they might be looking for or they wanna talk about it, we have that," he says. "We have a lot of that."

3. They're diversifying their offerings

Books may be their bread and butter, but many indies are adapting to the changing landscape by selling other stuff, too. At The Strand in Manhattan, 15 percent of the store's revenue now comes from things that aren't books: stationery, bags, T-shirts, and postcards.

"There's no reason to be a purist," says McIlroy, "but there's every reason to say, 'Well customers are coming in, what is it we can offer them that they'll give us cash for and make them like coming in here more than they did the day before?'"

4. They foster community

Author readings, kids events, and panel discussions all help make the independent bookstore not just a place to buy books, but a place to commune and exchange ideas. Unger says BookCourt hosts 30 events a month that bring in hundreds of people. "For so many families in Brooklyn, this is kind of like their living room," he says. "We can be a store that's a reflection of the community, supported by the community, and we can be a meeting place for people. On the weekends, this is always the place where people meet before movies. And we can rely on that."

Such hubs are beloved and fiercely defended by the locals they serve. When the Rizzoli bookstore in Manhattan was forced to close because the building's owners wanted to demolish it, customers rallied and started a petition to get the building classified as a landmark to prevent demolition. The petition failed, and the store reopened elsewhere, but that kind of attachment to a retailer is rare and rooted in a strong sense of community.

"Every store has its own reason why it survives," Unger says. "Every store has a different way of going about it. One thing we're just really grateful for is there's a community here that wants us to be here and so they make sure we're able to be here."