The coronavirus pandemic has been difficult from any number of viewpoints, but two companies that have navigated the challenges while capitalizing on their specific advantages are Costco (NASDAQ:COST) and Home Depot (NYSE:HD). Both retailers were able to remain open when others were mandated to close because they were deemed essential businesses. Both are also very good at what they do, but a close analysis will reveal which is the better buy at this time.

Membership has its privileges

Costco's June sales numbers were very impressive, with comparable-store sales (excluding the impact from changes in gasoline prices and foreign currencies) up more than 14%. The rise in e-commerce sales was 87%, showing how effectively Costco has been pivoting in that direction.

The membership-based business model has worked well. In exchange for high-margin membership fees, Costco provides customers with quality merchandise at prices that other big-box stores find difficult to compete with.

CEO Craig Jelinek said: "Costco is able to offer lower prices and better values by eliminating virtually all the frills and costs historically associated with conventional wholesalers and retailers, including salespeople, fancy buildings, delivery, billing, and accounts receivable. We run a tight operation with extremely low overhead which enables us to pass dramatic savings to our members."

The company has been international since 2013, and now has more than 700 warehouses worldwide. Last year, Costco opened its first warehouse store in mainland China. Consumer response was so enthusiastic that the store had to close early on opening day due to traffic jams and three-hour waits just to park.

The retailer's loyal customer base has a renewal rate of 90%. Costco also benefits from a smart management team adept at managing costs. Loyalty increased during the pandemic when Costco put the safety of employees and customers first, requiring social distancing and masks as early as May 4, ahead of other retailers.

A gloved hand holding up a facemask for shopping in a warehouse store.

Image source: Getty Images.

If you want it done soon, do it yourself

Home Depot is the world's leader in retail hardware with 400,000 employees and 2,291 big-box stores. Highly regarded by associates, suppliers, and customers, Home Depot was No. 21 on Fortune magazine's 2019 list of Most Admired Companies, and first in the specialty-retailer category.

Unlike many businesses, Home Depot has benefited from stay-at-home orders in the coronavirus pandemic since it was deemed an essential business. So when quarantined workers at other companies noticed their homes could use some sprucing up, they frequently turned to Home Depot for supplies to make fixes and upgrades.

Net sales in the first quarter increased by 7.1%, although diluted earnings per share fell by 8.4% due to higher expenses related to the health crisis. The company had to take an $850 million pre-tax charge, resulting in a hit to earnings of $0.60 per diluted share.

Home Depot should continue to hold up well despite uncertainty, thanks to its efforts integrating physical-store shopping with online shopping in a strategy called One Home Depot. Pandemic pressures sped up some aspects of implementation, but having the program already in place was prescient.

Home Depot stock has soared 39% in the past three months, and some think the upward trajectory will continue for some time to come.

"If you want a pool, you're now on a waiting list for 2021, for next year. You want a contractor to install an electrical outlet? Those are booking three months out. So, a lot of this stuff you've got to [do it yourself]," said Mark Tepper, CEO of Strategic Wealth Partners, citing anecdotal evidence from his home in Cleveland.

While the trend of sprucing up one's home seems likely to continue for the foreseeable future, Home Depot's 10% dividend increase takes the yield to about 2.27%. The payout ratio of about 54%, based on next year's estimates, indicates the dividend should remain safe.

Which stock is the better buy?

Costco stock is up 11% so far this year, while the S&P 500 index is up 0.2%. With a price-to-earnings ratio of 39, the company may seem richly valued, but the price-to-sales ratio is an attractive 0.84.

Home Depot stock is up 21% so far this year, and sports a P/E of 26. The company's P/S is 2.10.

Amid the pandemic-fueled uncertainty and risk, investors need to pay up for quality and growth. Both companies demonstrate those qualities, making this a tough call.

But I think Costco edges out Home Depot for the title of better buy at this time, mainly because of its successful international presence. Other countries are recovering and returning to retail while the U.S. is still struggling. Secondarily, I find the P/S ratio of 0.84 to be compelling.

I think making Costco a core holding at current price levels will reward investors for years to come better than Home Depot.