With the S&P 500 and the Nasdaq Composite Index both up by double digits in 2023, investors are feeling a sense of renewed optimism, particularly as the economic backdrop is looking surprisingly resilient. This has resulted in some growth stocks performing even better than the broader market.

Take Shopify (SHOP -0.58%), for example, whose shares are up 48% this year (as of Aug. 17). That gain has likely been catapulted by the acceleration of growth in the most recent quarter, as well as a general risk-on sentiment from investors.

Even though Shopify's stock has gone up nearly four-fold in the past five years, it still looks like a top e-commerce business you should consider buying and holding for the next decade. Let's take a closer look.

Shopify's recent numbers

Revenue totaled $1.7 billion last quarter (Q2 2023 ended June 30), up 31% year over year. That headline figure exceeded what Wall Street analysts were looking for. For the past several quarters, growth has been slower than the 57.4% gain registered in 2021, but the last quarter showed an acceleration in the business compared to Q1. And looking at the current quarter, management expects revenue to jump more than 20%, better than the Wall Street consensus forecast.

Gross merchandise volume (GMV) increased 17% to $55 billion, indicative of the size of Shopify's platform. It's important that this figure keeps increasing, but what's even more critical is Shopify's ability to monetize this activity. The attach rate, or the percentage amount of GMV the business counts as revenue, was nearly 3.1% during the second quarter, a record for the company.

Shopify appears to be getting on better financial footing. The recent sale of its logistics division could propel the business closer to reaching positive net income on a generally accepted accounting principles (GAAP) basis by driving costs lower. Adjusted operating income of $146 million in Q2 was a stark reversal from the $42 million loss posted in the year-ago period. And Shopify has produced positive free cash flow in the last three quarters, which investors should be encouraged about.

Attractive characteristics

As an e-commerce platform, Shopify benefits from the ongoing secular trend of online shopping. That's probably not surprising to most investors. But what might be a shocker is that even after more than two decades of the internet completely disrupting how commerce is done, just 15% of retail sales in the U.S. are represented by e-commerce. As a result, there's still a long runway for Shopify to progress.

The company's economic moat will help maintain its strong competitive standing for years to come. Shopify's various services lead to switching costs among its customer base. Once a merchant sets up their online shop on Shopify's platform -- while also utilizing other services like payments, marketing tools, and inventory management -- they are unlikely to switch service providers to avoid a burdensome process that could disrupt their operations.

Steep valuation

Before putting money into a stock, it's important that investors don't forget to look at the valuation. Even after Shopify shares took a hit in the past month, down 21%, they still trade at a price-to-sales (P/S) multiple of 11. That looks expensive despite being less than half the P/S ratio of 23 that the stock has averaged since going public in 2015.

Consensus analyst estimates call for Shopify's earnings per share to come in at $1.13 in 2027. Based on the current stock price of about $53, shares are trading at roughly 48 times that expected bottom-line figure. That doesn't scream cheap by any means. Clearly, a valid argument can be made that the stock isn't exactly attractively priced right now.

However, this is a fast-growth business that still has a large expansionary runway ahead of it, particularly as more shopping is done online over time. And thanks to its competitive advantage, Shopify should remain a leader in the space. As the company achieves greater scale and sales rise, the belief is that profits should skyrocket. That makes Shopify a top e-commerce stock to buy and hold for the next decade.