Brick-and-mortar retail doesn't have a lot of success stories, especially these days with the coronavirus pandemic slamming the industry.

However, Costco (NASDAQ:COST) and TJX Companies (NYSE:TJX) are each leaders in their respective niches of the retail sector, and have a set of unique competitive advantages that have made them among the best retail stocks to own. Operating as a membership-based warehouse retailer, Costco has a loyal customer base that keeps returning for its rock-bottom prices and unique product selection. Off-price leader TJX, the parent of TJ Maxx, Marshall's, and Home Goods, is also known for its bargain prices on apparel and home goods, as well as its frequently-rotating inventory, which creates a so-called treasure-hunt experience, meaning shoppers will never find the same assortment twice.

A scale with coins on each side

Image source: Getty Images.

Costco and TJX's approaches have made each company relatively protected from e-commerce competitors like Amazon, and they continue to open new stores. As you can see from the chart below, both stocks have handily outperformed the S&P 500 over the last decade.

COST Chart

COST data by YCharts

Investors looking for a strong retail stock may be struggling to choose between the two. Let's take a look at what each company has to offer today to determine which is the better buy.

Costco: A coronavirus-proof customer favorite

As a consumer staples heavyweight, Costco is made to endure difficult periods like the coronavirus pandemic. Customers rely on the warehouse club for everything from food to household products like paper goods to appliances and electronics, and even apparel and home goods. The company's straightforward business model and rock-bottom prices have created a loyal customer base, and retention rates are around 90%. Costco actually makes most of its profit from membership fees, selling goods near cost -- so as long as it can retain members, its business will remain strong.

During the pandemic, the company has been a virtual lifeline for customers. Its stores were mobbed during the stocking-up period, and have remained busy as consumers have spent more money at grocery stores and warehouse clubs while options like restaurants, travel, and entertainment have been limited. In June, comparable sales excluding fuel and foreign exchange jumped 13.6% in the U.S. and 14.4% globally, showing customers are flocking to its stores and its website; e-commerce sales jumped 85% last month. 

Costco has 15 new store openings planned for the next few months, and is investing in e-commerce, an area it's traditionally lagged in, with its March acquisition of Innovel Solutions, which specializes in last-mile delivery for big and bulky products. 

During an uncertain time, Costco is one of the few stocks you can count on to continue to deliver solid results, and is one of the safest investments on the market today.

TJX Companies: A challenge and an opportunity

As a consumer discretionary retailer, TJX is in a much different position from Costco. The company closed all of its stores during the lockdown period and even shut down its websites, which only generate a small percentage of its sales, for safety reasons. Like other discretionary retailers, TJX took other measures to conserve cash, including suspending its share buyback program, drawing down $1 billion from a revolving credit facility and reducing capital expenditures. It furloughed store-level employees in April, and in May said it wouldn't pay a dividend for the first half of the year.

While the pandemic has been a shock to the business, TJX is in a much stronger position than many of its peers as the economy reopens. A number of its competitors have already declared bankruptcy. Its locations in high-traffic strip malls and urban corridors give it an advantage over malls, which are particularly vulnerable to the pandemic as large indoor environments, and the recessionary climate should drive the kind of bargain hunting that the company thrives on.

In its first-quarter earnings report, management reported that sales were up at reopened stores, a sign of pent-up demand as consumers eagerly returned to chains like TJ Maxx and Home Goods. The massive dislocation in the retail industry also sets up the company to get a bevy of cheap inventory, as its business model functions by sourcing discounted products from canceled orders, closeout sales, and other such opportunities.

Though the company clearly faces near-term challenges, in a best-case scenario it could see thinned-out competition, increased real estate vacancies -- making expansion easier -- a steady flow of merchandise from failing rivals, and elevated demand from customers hungry for deals. It's easy to see how the pandemic could ultimately be a golden opportunity for the company to grab market share.

And the winner is...

Both stocks have a lot to offer investors: They're the respective leaders of their retail subsectors, and they have a proven set of competitive advantages and ample growth opportunities. However, the pandemic has introduced a degree of uncertainty into the future that Costco is much better prepared for. While TJX could emerge from the crisis in a better position, especially compared to its peers, the company lost nearly $1 billion in the first quarter, and analysts expect a loss in the second quarter as well, along with a 34% drop in revenue. For now, TJX's financial position is getting worse, and it could be a while before it improves.

Costco, on the other hand, is seeing sales surge, and that pattern is likely to continue for the duration of the pandemic, as spending more time at home will mean more stocking up at stores like Costco. Paid membership increased by 2.7 million to 55.8 million in the most recent quarter, and membership should continue to move higher as Costco provides a valuable service during tough times.

Both stocks still look like they can outperform the broad market over the long term, but Costco's reliability and ability to withstand the impact of the pandemic make it the better buy today.