Costco (COST -0.24%) and Home Depot (HD 0.74%) both survived the retail apocalypse that wiped out many brick-and-mortar retailers over the past decade. Costco's sticky membership plans, low prices, and sales of bulk products locked in its shoppers, while Home Depot's wide selection of home improvement items -- many of which were difficult to buy online -- shielded it from Amazon and other mass retailers.

Both companies also expanded as other retailers retreated. Costco ended its latest quarter with 848 warehouses worldwide, compared to 741 warehouses at the end of fiscal 2017 (ended in September 2017). Home Depot's store count rose from 2,284 stores at the end of fiscal 2017 (ended in January 2018) to 2,322 locations at the end of fiscal 2022.

A parent shops with a child at a big box retailer.

Image source: Getty Images.

Over the past five years, Costco and Home Depot generated total returns of nearly 170% and 80%, respectively, compared to the S&P 500's total return of just over 50%. But will these two resilient retailers continue to outperform the market this year?

The differences between Costco and Home Depot

Costco and Home Depot target different markets. Costco sells a wide range of groceries, sundries, appliances, electronics, and clothing at low prices, while Home Depot primarily sells home improvement products.

Therefore, inflation and other macro headwinds affect Costco and Home Depot differently. Costco experienced slower sales of big ticket items like electronics and appliances over the past year, but it largely offset that pressure with brisk sales of groceries and household essentials. Home Depot's growth is tightly tethered to the housing market, which stalled out as rising interest rates prevented potential buyers from applying for new mortgages.

Costco generates most of its profits from its annual membership fees, which enable it to sell most of its products at lower prices than other retailers. Home Depot doesn't charge any membership fees. Instead, it offers a free rewards program called Home Depot Pro that provides contractors and other professionals with exclusive discounts and perks.

Costco also has more exposure to currency headwinds than Home Depot, since a higher percentage of its stores are located overseas. Some 31% of Costco's stores are located in other countries, compared to 14% of Home Depot's stores.

Which company will grow faster in this market?

Costco's revenue rose 16% in fiscal 2022 (ended last August) as its adjusted comparable store sales (which exclude gas and currency fluctuations) grew 11%. Its earnings per share (EPS) increased 17%.

In the first half of fiscal 2023, its revenue grew 7% year over year, its adjusted comps increased 7%, and its EPS rose 8%. That slowdown was relatively mild compared to other retailers that struggled with tough year-over-year comparisons to the pandemic and inflationary headwinds.

Costco's number of cardholders still rose 7% year over year to 123 million in the second quarter, while its global renewal rate rose 90 basis points to 90.5%. That stickiness indicates its core profit engine is still firing on all cylinders. Analysts expect its revenue and earnings to grow 7% and 11%, respectively, for the full year.

Home Depot's revenue grew 4% in fiscal 2022, its comps rose 3%, and its EPS increased 7%. But for fiscal 2023, it expects its revenue and comps to be "approximately flat" as its EPS declines by the "mid-single digits." Analysts expect its revenue to stay roughly flat as its earnings dip 5%. It attributes that slowdown to a "moderation in demand" for home improvement goods as the sector grapples with inflation, rising rates, a tight labor market, and sluggish home sales.

However, it believes it can offset some of that pressure by expanding its dominant market share in the home improvement space. That could be bad news for Home Depot's closest competitor Lowe's, which is already bracing for a 0%-2% comps decline in fiscal 2023 (ending in February 2024).

Which stock is the better buy right now?

Costco clearly faces fewer near-term headwinds than Home Depot, but it's also priced accordingly. Costco trades at 34 times forward earnings and only pays a forward yield of 0.8%. Home Depot has a lower forward price-to-earnings ratio of 18 and pays a higher forward yield of 2.9%.

Home Depot might seem like a better buy as the bear market drags on, but its heavy exposure to the housing sector could hold it back. It's also easy to find other cheap dividend stocks that pay higher yields but are more resistant to the near-term macro headwinds.

Costco isn't cheap, but it should remain resilient in this tough market because it generates the most balanced growth. Its high multiple might limit its upside potential this year, but I think it's still a better overall investment than Home Depot.