Some television shows offer contestants the possibility of becoming a millionaire within a couple of hours, days, or weeks. That's a tough thing to do in the stock market. But investing in great stocks and holding them for, say, 10 years could turn your initial investment of $200,000 into $1,000,000.

For those keeping score at home, that's a compound annual growth rate (CAGR) of about 17.5%. Let's look at two e-commerce companies that have the potential to deliver these kinds of returns in the next decade: Shopify (SHOP -2.04%) and Etsy (ETSY -0.48%).

SHOP Chart

SHOP data by YCharts

1. Shopify

Let's start with Shopify's bad news. While the company has performed exceptionally well since its 2015 IPO, it lagged the market in the past year. That's likely because it was significantly overvalued. Even after its poor showing over the past 12 months, Shopify's forward price-to-earnings (P/E) ratio is 169.1. The industry's average forward P/E is 47.3. Stocks with rich valuations metrics tend to fall harder than the broader market at the slightest hint of marketwide troubles -- and they often get severely punished when they fail to live up to their lofty expectations. That's why investors should expect some volatility in the near term.

Now for the good news: While there may be temporary headwinds related to valuation, Shopify's long-term prospects remain intact. The company's future is tied, to some extent, to the growth of the e-commerce industry. But in the U.S., e-commerce sales accounted for just 13% of total sales in the third quarter of 2021. That gives the sector a long runway for growth, as some analysts have estimated. Meanwhile, Shopify continues to record excellent top-line growth.

In the third quarter, the company's revenue soared by 46% year over year to $1.1 billion. That was on the back of a 35% year-over-year increase in its gross merchandise volume (GMV) -- the total value of transactions conducted on its platform -- which clocked in at $41.8 billion for the quarter.

On the bottom line, Shopify's adjusted net income decreased to $102.8 million, down from the $140.8 million it recorded during the year-ago period.

Person lying on a bed in front of a laptop with a credit card in one hand.

Image source: Getty Images

Shopify hasn't been profitable for very long. It's not surprising to see its earnings not consistently growing yet, as it continues to invest heavily in its future. But I think the company's master plan will eventually pay off. One major reason why Shopify has such a bright future is that its platform boasts a competitive edge -- namely, high switching costs.

Imagine spending weeks crafting the perfect online storefront for your business then spending several months attracting clients to this website. Starting the whole process from scratch would require you to invest this much time and effort in the task all over again, not to mention it may lead to the loss of some of your customers.

This dynamic explains why Shopify keeps most of its customers while adding new ones. The company had roughly 1.7 million merchants on its platform at the end of 2020 compared to about 820,000 at the end of 2018. A growing number of merchants, combined with the company's strong competitive advantage and increased adoption of e-commerce worldwide will work wonders for this tech stock in the next decade and beyond.

2. Etsy

Etsy's platform specializes in connecting vintage- and handmade-goods sellers with potential buyers. It's one of the leading platforms in this niche space, and its specialty confers a competitive edge: the flywheel effect. Buyers of these specialized items will flock to the platform where it's most likely that they'll find what they're looking for, which, in turn, will attract a greater number of sellers seeking a vast consumer base, and so on. 

That's why Etsy continues to record an increasing number of buyers and sellers on its website. In the third quarter, the company's number of active sellers soared by 102.7% year over year to 7.5 million. Active buyers increased to almost 96 million, 37.8% higher than the year-ago period. The rest of Etsy's results looked pretty solid, too.

The company's revenue increased by 17.9% to $532.4 million, while gross merchandise sales increased by 17.9% to $3.1 billion. However, Etsy's net income decreased by a modest 2% to $89.9 million.

Just like Shopify, Etsy has lagged the market in the past year. And just like Shopify, that's likely due to investors shifting away from richly valued stocks. Etsy's forward P/E currently stands at 45, which is near its 52-week low.

The market may continue to punish stocks such as Etsy for a bit longer, but investors shouldn't be too bothered by that. Etsy estimates its total addressable market (TAM) to be worth roughly $1.7 trillion (and growing).

To capture even a fraction of that, which would help its revenue and net income soar, Etsy's investing heavily in optimizing its platform to make it easier for sellers to navigate. One thing Etsy has focused on is its platform's ability to make appropriate recommendations based on the shopping habits of its sellers.

As the company's CEO Joshua Silverman said:

We're investing aggressively in machine learning tools attempting to understand your tastes and preferences in order to anticipate and inspire your next purchase. We want to make Etsy feel truly made for you. For those buyers on a specific shopping mission, we're focused on driving efficiency, a fast and easy shopping experience.

An easier shopping experience will likely translate to higher gross merchandise sales, revenue, and profits over the long run. Thanks to initiatives like these (and others), investors can rest assured that Etsy will continue to make headway within its massive TAM. Clocking in a 17.5% CAGR in the next decade seems well within Etsy's reach.