Over the past five years, Costco (COST 1.42%) shares have climbed 159%, easily crushing both the S&P 500 and the Nasdaq Composite Index. Strong revenue and earnings growth, which have admittedly slowed recently, have been key to the stock's impressive returns.

Costco is well known for relentlessly focusing on providing the lowest prices to its customers in an exceptional shopping environment. But let's take a closer look at the company's secret ingredient that has also contributed tremendously to its success. It just might make the top retail stock a no-brainer buy right now. 

Costco's recurring revenue stream

The retail sector is incredibly competitive, with businesses doing whatever they can to drive greater traffic and sales in an environment where customers have unlimited options to choose from. Costco stands out from the crowd because of its low prices -- the average markup on its products of 11% is far lower than other big-box retailers. This strategy has worked, as evidenced by the fact that Costco is the world's third-largest retailer.

But critical to the company's success is its membership-based operating model. Not just anyone can shop at Costco's 852 warehouses. You must pay $60 for the basic plan or $120 annually for the Executive option to be able to shop at Costco locations. As of May 7, there were 69.1 million membership households.

This provides the company with a steady stream of recurring revenue. Membership fees totaled just over $1 billion in the most recent fiscal quarter (Q3 2023 ended May 7), up 6% year over year. That figure seems trivial compared to Costco's merchandise revenue of $52.6 billion last quarter, but because memberships carry very high margins, this revenue source is of the utmost importance to Costco's bottom line. Without memberships, the company would be just another low-margin retailer.

Besides providing high-margin, recurring revenue, memberships result in customer loyalty. When choosing between where to get groceries or a new TV, for example, a consumer might favor Costco simply because they are a member there. This helps to drive repeat purchase behavior. During the most recent quarter, the membership renewal rate was 92.6% in the U.S. and Canada and 90.5% worldwide, both impressive figures. 

Moreover, Costco's membership benefits from its own pricing power. CFO Richard Galanti has indicated that the business will raise the annual fee "at some point." The last time this happened was in June 2017. A price increase will provide a huge boost to Costco's profits.

There's one reason not to buy shares

I don't think there's any debate that Costco is a wonderful business. Its massive scale allows it to obtain favorable pricing on its products, savings that are passed to consumers in the form of low prices. And its memberships provide a lucrative revenue source, as well as keep customers hooked. During a time that included the pandemic followed by high inflation, Costco thrived, with its annual sales growth exceeding more than 15% in two straight fiscal years (2021 and 2022), well above historical norms.

However, the stock's valuation isn't attractive right now, trading at a price-to-earnings (P/E) multiple of 39.3. That's not only more expensive than the stock's trailing five- and 10-year average valuations, but also higher than rivals Walmart and BJ's Wholesale Club. This presents some downside risk to shares should earnings disappoint Wall Street analysts in the near term, or if shareholders simply feel like taking profits and exiting their positions.

For some investors, though, it might be worth paying a premium price for such a superb company -- one that provides safe, reliable, and steady growth.