Amazon (AMZN -1.64%) and Etsy (ETSY -2.17%) both soared during the earlier stages of the pandemic. Amazon won as shoppers flocked to its e-commerce platform for essentials. And Etsy won as consumers shopped online for face masks and other handmade items. But these companies' successes aren't just linked to the health crisis. Both already were growing revenue well before the pandemic. And there are plenty of reasons why that should continue well into the future.

At the same time, both stocks have suffered along with the general indexes this year. Amazon has dropped about 38%, while Etsy has lost 68%. Which stock is a better buy considering valuation and future prospects? Let's find out.

The case for Amazon

Rising inflation is weighing on Amazon right now. But here's the good news. This is an external problem and it's temporary. So once the situation improves, the e-commerce business should benefit. Meanwhile, Amazon is working on managing the costs that are within its control. That's about two-thirds of incremental costs, the company said during its first quarter earnings report. Amazon also made a big investment recently. It doubled its fulfillment network in just two years. This is costly in the near term. But over the long term, the move is likely to pay off.

And while the e-commerce business may not be easy at the moment, another business is driving growth at Amazon. I'm talking about cloud computing. Amazon Web Services (AWS) is the market leader. It's held between 32% and 33% of the market over the past few years, according to Synergy Research Group. In the most recent quarter, AWS reported double-digit gains in sales and operating income. And this business traditionally has represented a majority of Amazon's operating income.

As for valuation, Amazon is trading at 121 times forward earnings estimates. That's down from about 200 just two months ago. Considering the ongoing strength of AWS and the potential for e-commerce to pick up speed down the road, this looks like a bargain.

The case for Etsy

Etsy, too, has seen a slowdown from growth earlier in the pandemic. Consumers aren't spending as much as they used to on discretionary items due to the economic situation. Still, Etsy managed to report a 3.5% increase in gross merchandise sales to more than $3 billion in the first quarter. And one very positive point for Etsy these days is it isn't as exposed to supply chain troubles as other retailers. That's because Etsy's sellers are small shops, often run by artisans at home or in a workshop. And they don't rely on huge shipments of supplies across long distances.

Another plus for Etsy is its connection with its audience. The company serves 89 million active buyers in about 250 countries. And buyers often keep coming back. Among buyers that identify as women, 58% made purchases on two or more days in a 12-month period. For buyers who identify as men, that figure is 37%. In the first quarter, Etsy added seven million new buyers. That's higher than in pre-coronavirus times. To keep that customer loyalty going, Etsy is investing to make its platform even better. The company recently improved page load times on its mobile platform, for example, and upgraded its search and discovery tools.

Etsy shares are a steal right now considering the company's long-term potential. The stock is trading at only 19 times forward earnings estimates -- down from more than 48 at the start of the year.

Amazon or Etsy?

Both companies are suffering from the fact that consumers are buying fewer non-essentials these days. Most retailers face this situation. Amazon has the advantage of selling essentials too, such as grocery items. As for Etsy, its advantage lies in the fact that it doesn't have to worry about supply chain issues, as mentioned above.

I'm positive about both of these stocks over the long term. So, choosing just one to buy now is tough. But if I absolutely have to, I'll go with Amazon. The retail giant can rely on its cloud computing business to carry it through these tough retail times. And Amazon also benefits from its offering of essentials. The company's upcoming Prime Day sales event -- July 12 and 13 -- could offer an additional lift. All of this means right now may be a great moment to get in on Amazon.