Retail giants Costco (COST -0.12%) and Best Buy (BBY 1.09%) both experienced accelerating sales growth throughout the pandemic. Costco became a top destination for stocking up on essential products, while Best Buy benefited from surging PC sales as more people worked from home.

Costco's stock price rose by over 20% in the past 12 months, but Best Buy's stock price more than doubled. Let's see why investors were more enthusiastic about Best Buy this past year, and whether that trend will continue this year.

A tale of two big retailers

Costco's warehouse club model, which lets members buy products in bulk at lower prices than superstores or Amazon, insulated it from the worst effects of the retail apocalypse over the past decade.

Boxes of electronics and home appliances.

Image source: Getty Images.

As other brick-and-mortar retailers crumbled, Costco expanded its store count from 686 locations at the end of fiscal 2015 to 804 locations in the second quarter of fiscal 2021. It generates nearly all of its profits from its membership fees, so it can afford to sell its products at razor-thin margins or losses.

Best Buy was once considered the next victim of the retail apocalypse. It was losing shoppers to Amazon, superstores, and other retailers, and its visitors often used its stores as showrooms to test out products for online purchases elsewhere.

But Hubert Joly, who led Best Buy between 2012 and 2019, pulled the retailer back from the brink. Joly fixed Best Buy's broken inventory systems, invested in better employee training, matched Amazon's prices, expanded its e-commerce ecosystem, and turned its stores into fulfillment centers for online orders. The company even embraced its reputation as a "showroom" by renting out its floor space to big brands.

Best Buy also didn't retreat as other brick-and-mortar chains struggled. Its total store count remained stable, rising slightly from 1,130 locations to 1,159 locations between fiscal 2016 and 2021.

Which survivor is growing faster?

Costco's revenue rose 9% to $166.8 billion in fiscal 2020, which ended last August. Its comparable-store sales grew 9.2%, its e-commerce sales surged 50%, and its EPS increased 9%.

A shopping cart in a supermarket aisle.

Image source: Getty Images.

In the first half of fiscal 2021, Costco's revenue rose 16% year over year to $88 billion. Its comps grew 15%, its e-commerce sales soared another 80%, and its EPS increased 19%. It mainly attributed that acceleration to rising purchases of household essentials during the pandemic.

Costco's membership renewal rate in the U.S. and Canada expanded year over year from 90.9% to 91% in the second quarter. Its global renewal rate also expanded, from 88.4% to 88.5%. Those sticky subscription plans should keep Amazon, Walmart's Sam's Club, and other challengers at bay.

Analysts expect Costco's revenue and earnings to rise 12% and 14%, respectively, this year. But next year, they expect its revenue and earnings to grow just 7% and 10%, respectively, as it faces tougher year-over-year comparisons after the pandemic ends.

Best Buy's revenue rose 8% to $47.3 billion in fiscal 2021, which ended this February. Its total comps increased 9.7%, with 144.4% digital comps growth in the U.S., and its adjusted earnings jumped 30%.

Best Buy's growth was primarily fueled by robust demand for PCs, appliances, gaming, virtual reality, and home theater products throughout the pandemic, which was partly offset by lower sales of headphones and mobile phones.

Best Buy's sales of PCs should decelerate after the pandemic ends, but new gaming consoles like the PS5 and Xbox Series X, new 5G phones, and the expansion of its newer digital health business could pick up the slack. Analysts expect Best Buy's revenue and earnings to dip 1% and 8%, respectively, this year, before accelerating again in fiscal 2023.

The valuations and verdict

Costco stock trades at 33 times forward earnings and pays a forward yield of 0.8% on its dividend. The stock looks a bit pricey relative to its growth, but its sticky subscriptions, wide moat, and ongoing expansion could justify that slight premium.

Best Buy stock trades at 15 times forward earnings and pays a higher forward yield of 2.4% on its dividend. It's cheaper because it will generate slower near-term growth after the pandemic, but its low valuation could make it more appealing than Costco as higher bond yields spark a rotation from growth stocks to value stocks.

I personally like both stocks, but Best Buy stock looks like a safer investment than Costco right now. Best Buy is adopting the same strategies that made Walmart and Target such great retail plays over the past few years, and it should continue to generate impressive gains in the future. Costco is still a solid evergreen investment, but its high valuation could limit its near-term gains.