E-commerce companies took a hit last year as inflation caused reductions in consumer spending. Many of the sector's most prominent players experienced steep stock declines as a result.

But the long-term outlook for the e-commerce industry remains positive. Data from Statista is projecting it to hit $4 trillion this year. Meanwhile, online purchases only made up about 15% of all retail sales last year, suggesting the market is nowhere near hitting its ceiling.

As a result, now could be the perfect time to consider adding an e-commerce stock to your holdings before the market fully recovers. So, here are three top e-commerce stocks to buy in June. 

1. Amazon

With its dominance in the industry, it's hard not to mention Amazon (AMZN -1.65%) when discussing e-commerce stocks. The company has a massive lead in the market with its 38% share; Walmart holds the second-largest share at 6.3%. Amazon's authority in e-commerce means it has the most to gain from easing inflation and a market recovery.

However, that also meant it had the most to lose from last year's macroeconomic headwinds. In fiscal 2022, the company's e-commerce segments reported operating losses totaling $10.6 billion. Amazon managed to stay profitable thanks to earnings from its cloud platform Amazon Web Services, but the losses still caused its stock to plunge 50% throughout the year.

Despite the recent challenges, a reduction in inflation and various cost-cutting measures seem to have the company back on a growth path. The first quarter of 2023 saw Amazon's North American segment return to profitability, with operating income hitting $898 million, while its international segment also reported a marginal improvement.

Amazon's e-commerce business struggled last year, but it seems to be back on a growth path. And this June is potentially an excellent time to invest in it. 

2. PayPal

PayPal Holdings (PYPL -1.14%) doesn't sell physical products online, but its business heavily relies on the e-commerce market's performance. The company holds a 42% market share in online payment software, making it the go-to choice for online retailers seeking an alternative to credit and debit cards. However, like Amazon, PayPal's authority in the market led to steep declines last year, with its stock plummeting 62% in 2022.

Investors grew skeptical after an economic downturn and increased competition in the fintech arena. Yet, PayPal's financials suggest there are still reasons to rally around the company. Since 2019, annual revenue rose 55%, hitting $28 billion last year. Operating income climbed 41% in the same period.

The discrepancy between Wall Street's apprehension and PayPal's earnings has made the stock a bargain buy. The forward price-to-earnings ratio is just above 12 after decreasing by 40% in the last 12 months. The figure suggests the stock is currently undervalued, with this month an exciting time to invest. 

3. Costco

As e-commerce giants go, Costco Wholesale (COST -0.12%) is not in the same league as Amazon or Walmart. However, with its online retail business still in its infancy, the company could offer significant gains as it expands. 

While companies like Walmart, Target, and Coupang are thriving e-commerce businesses, their reach does not extend outside their countries of origin. Meanwhile, Costco has a global presence, operating in about 14 countries and counting. As a result, the company has more opportunities for growth as it delves deeper into online retail. 

In 2021, Costco doubled down in its e-commerce division by increasing its number of pickup-locker locations, which allow consumers to order select items online and retrieve them from different pickup points.

The company plans to expand its Costco Next brand, which launched in 2017 and offers club members the option to buy products directly from trusted suppliers for about 20% less than the standard recommended retail price. The program incentivizes consumers to keep their Costco membership rather than straying toward the competition. 

Costco shares rose 158% in the last five years and 367% over the last decade. The company has a history of consistent growth. Alongside a solid outlook in e-commerce, it might be worth investing in Costco stock this June.