Betting on e-commerce is a great idea and here's why: The market is expected to climb in the double digits this decade. And we all see how common it is for people to shop online for everything from groceries to unique gifts. So, over time, e-commerce companies that stand out from the crowd are likely to benefit, and as an investor in them, so should you.

Two top names to consider are Amazon (AMZN -0.40%) and Etsy (ETSY -0.32%). Amazon focuses on selling general merchandise and groceries. Etsy brings together sellers and buyers of handmade and vintage items. Both saw growth explode during the earliest stages of the pandemic. Recent economic woes have weighed on the companies though. Which is the better buy right now? Let's find out.

The case for Amazon

Amazon has faced its share of challenges in recent times. Rising inflation lifted its costs and hurt the buying power of its customers. The company also has struggled with excess capacity after a rapid build-out of its fulfillment network.

But there are two big pieces of good news: First, Amazon launched a plan to cut costs and spur growth -- and it's making progress. In its first-quarter earnings report, revenue, net income, and operating margin all beat analysts' estimates. Operating cash flow increased 38%. And free cash flow improved to a smaller outflow -- $3.3 billion versus $18.6 billion in the year-earlier period.

All of this shows Amazon's efforts to manage difficult times are working. We can't expect an overnight turnaround, but this positions the company well for the future.

Now for the second piece of good news: Today's tough economic situation is temporary. And Amazon's bright, long-term outlook hasn't changed. In e-commerce, efforts Amazon is making now should help it excel over time. For instance, it predicts it will record the fastest Prime program-delivery times ever this year. That could keep Prime customers coming back.

Amazon's cloud-computing business -- which generally drives profit -- still is seeing clients on tight budgets. The company's efforts to offer them cheaper data-storage products may weigh on profit now. But that's OK because it should keep customers loyal for the long haul. And that's great news for future earnings.

The case for Etsy

Like Amazon, Etsy has felt the impact of economic troubles. Consumers have less money to spend, especially on the discretionary sorts of items generally found on Etsy. Still, the company has managed to keep the growth it gained during the earlier stages of the pandemic when people favored buying online.

Etsy marketplace gross-merchandise sales last year totaled more than $11 billion. That's compared to $4.7 billion in 2019. This is a very good sign because it shows Etsy wasn't just a pandemic stock or a trend of the moment. Shoppers truly do see the value of choosing this e-commerce player.

In the most recent earnings report, Etsy said active buyers have climbed 95% over the past three years. And habitual buyers have increased 194% over the three years to 7.4 million. Habitual-buyer growth is particularly important because it shows Etsy has a solid base of shoppers it can rely on.

Etsy also has benefited from its cost control and its work to make every marketing dollar count. It's spending more on marketing than it did in previous years. But marketing spend as a percentage of revenue is on the decline.

As a result of all of this, Etsy in the most recent quarter reported record revenue; consolidated non-GAAP adjusted earnings before interest, taxes, depreciation, and amortization (EBITDA); grew its free cash flow; and ended last year with $1.2 billion in cash.

Amazon or Etsy?

Both of these e-commerce stars are likely to shine in the future. So I would be happy to add Amazon and Etsy to my portfolio right now. But if I had to choose just one to buy, I would go for Etsy.

Here's why: Amazon shares have already gained about 25% so far this year, and it may take a while for the company to truly recover and offer catalysts to support a significantly higher share price.

Etsy's stock has been in the doldrums. It's lost 15% this year, leaving the stock trading for 24 times forward-earnings estimates. This looks very reasonable considering Etsy's performance through tough times and its ability to keep buyers coming back. At this point, any good news from Etsy could offer the stock a boost. And the company has the right strategy to keep the gains going over the long haul.