The S&P 500 slipped into a bear market 16 months ago, and the index is still down 14%. But history says the drawdown is temporary. The S&P has suffered numerous bear markets in the past, and each one has ended in a new bull market. There is no reason to expect a different outcome this time.

In the meantime, investors have an opportunity to buy shares of Shopify (SHOP -2.37%) and Roku (ROKU 0.15%) at discounted prices. Here's why both growth stocks are worth owning for the long haul.

Shopify: The leading e-commerce software vendor

Shopify has been up and down like a roller coaster over the last few years. Sales growth accelerated during the pandemic as merchants raced to establish a digital presence, and its bottom line soared nearly ninefold in 2021.

Then growth decelerated and profitability vanished last year as digital tailwinds gave way to economic headwinds. But the tide appears to be turning once again. Shopify recently reported strong first-quarter results.

Revenue increased 25% to $1.5 billion, an acceleration from 22% growth last year, and Shopify reported positive cash from operations of $100 million, up from a loss of $25 million in the prior year.

Of course, some experts expect a recession this year, so investors should be cautious with their optimism in the near term. But the long-term investment thesis for Shopify remains rock solid.

The company provides unparalleled flexibility and support for its merchants' businesses. Its software connects physical and digital storefronts to create a dashboard from which they can manage orders and inventory across online marketplaces like Amazon, social media like Meta Platforms' Instagram, and direct-to-consumer websites. Shopify also provides an array of adjacent solutions that address everything from financing and payment processing to marketing and logistics.

Not surprisingly, Shopify is the leading vendor of e-commerce software as measured by market presence and user satisfaction. That puts the company in an enviable position. Retail e-commerce sales are forecast to increase by 9% annually to reach $8.1 trillion worldwide by 2026, and Shopify is very well positioned to benefit from that tailwind. But the company is also working to strengthen its competitive position by bringing larger brands to its platform.

It recently launched Commerce Components, a product that provides à la carte access to the Shopify tech stack. Specifically, it allows enterprises to integrate individual components of the platform (e.g., solutions for storefront development, inventory management, or checkout) with their own commerce infrastructure.

Readers might be familiar with Shopify Plus, a commerce platform built for larger brands. Commerce Components fits in the same category. It extends the company's ability to serve larger brands, but it does so in a milder way. Enterprises don't have to rip and replace their entire commerce infrastructure. They can adopt one Shopify component at a time.

Currently, shares trade at 13.8 times sales, a discount compared to the three-year average of 32.6 times sales. That creates a reasonable buying opportunity for patient investors.

Roku: The leading streaming platform

Roku has struggled amid the challenging economy. Demand for streaming players and smart TVs has declined in response to high inflation, and many brands have cut their ad budgets to compensate for soft consumer spending.

Those headwinds led to dismal financial results last year, and Roku has continued to struggle this year. First-quarter revenue rose just 1% to $741 million, and the company reported a loss of $194 million. But those dismal results come with a silver lining for patient investors.

Roku stock has fallen 88% from its high, and shares currently trade at 2.5 times sales, an absolute bargain compared to the three-year average of 12.6 times sales. More importantly, that price looks cheap given its growth prospects. Roku is the most popular streaming platform in the U.S., Canada, and Mexico as measured by hours streamed, meaning it engages viewers more effectively than its peers. That makes it a valuable advertising partner for brands,

So what? Connected TV (CTV) ad spend in the U.S. alone is expected to increase at 17% annually to reach $100 billion by 2030, according to BMO Capital Markets. And online video ad spend is expected to increase at 14% annually to reach $362 billion worldwide by 2027, according to Omdia. Roku is in the perfect spot to benefit from those tailwinds, perhaps more so than any other company. But it has other irons in the fire, too.

It recently launched a lineup of smart-home devices, and debuted its first company-made smart TV. Those hardware products should bring more users onto the Roku platform, increasing its value as an advertising partner.

The company is also experimenting with "shoppable" ads. Specifically, recent partnerships with Walmart and DoorDash allow viewers to make purchases from ads shown on the platform.

Here's the bottom line: Roku is the market leader in streaming platforms, so the company should benefit greatly as brands shift ad budgets toward ad-supported CTV programming. Roku OS is also the most popular smart-TV operating system in the U.S., Canada, and Mexico, which hints at significant brand authority and consumer loyalty. That should help it maintain its leadership among streaming platforms.

For all of those reasons, this stock is worth buying ahead of the next bull market.