The major stock market indexes have surged this year, and plenty of stocks have rocketed higher in recent months. Two soaring stocks that could keep rewarding investors in the long run are Cloudflare (NET 1.44%) and DigitalOcean (DOCN 3.30%). Here's why these two cloud companies are worthy of your investment dollars.

Cloudflare

Shares of edge computing leader Cloudflare have bounced back hard after tumbling in April. Cloudflare's first-quarter earnings report was mildly disappointing, with mixed results and an outlook that fell short of expectations.

The stock briefly crashed in reaction to that report but has fully erased those losses over the past month. Cloudflare stock is up nearly 70% from its early May low.

Cloudflare is starting to feel some pain from a tough economic environment. Revenue grew by 37% year over year in the first quarter, the slowest pace in years. The paying-customer count expanded by just 13%, and dollar-based net retention slumped to 117%, a full 10 percentage points lower than the same period last year.

Part of the problem for Cloudflare is that its sales organization isn't as productive as it needs to be. The company's platform has become complicated as new products and services have been launched, and the era of the core product largely selling itself is over as businesses pull back on spending. Cloudflare is refreshing its sales teams, but it will take time for these changes to bear fruit.

While the short-term picture for Cloudflare is muddled, the company's long-term opportunity could drive the stock much higher in the coming years. Cloudflare's knack for leveraging its global edge network to launch new products has led to a vast expansion in the company's total addressable market.

Back in 2018, when Cloudflare was focused on content delivery and basic security, the company estimated its market opportunity at $32 billion. Today, that number stands at $146 billion, and Cloudflare expects it to grow to $204 billion by 2026. The company's application-developer platform, which can remove the need for traditional cloud computing platforms, represents a massive growth opportunity.

Cloudflare stock is certainly expensive, trading for around 18 times the company's guidance for full-year revenue. But the company's growth story is still in its early innings, and it should be able to reaccelerate growth once economic conditions improve.

DigitalOcean

Like Cloudflare, DigitalOcean offers an alternative to the big cloud computing platforms. While Cloudflare focuses on serverless cloud computing that eliminates the need to manage servers, DigitalOcean takes a different approach.

Instead of an overwhelming menu of overlapping products and services with complicated pricing schemes -- something you'll find on Amazon Web Services and other leading cloud platforms -- DigitalOcean sticks to the basics and keeps pricing simple. Spinning up a virtual server on DigitalOcean's platform is easy, and through its acquisition of Cloudways, the company now offers a variety of managed options that solve a variety of problems for developers.

Shares of the company have been soaring, and for good reason. The stock is up about 84% since the start of the year, driven in part by a string of solid results.

Revenue jumped 30% year over year in the first quarter, and average revenue per user rose 16% to $88.35. For 2023, DigitalOcean expects to produce revenue between $700 million and $720 million, representing growth of 23% at the midpoint.

While the company's growth will slow this year, free-cash-flow generation is set to improve dramatically. The company expects to convert as much as 22% of its revenue into adjusted free cash flow in 2023.

DigitalOcean relies on its content library and word of mouth to drive sales, allowing it to spend very little on sales and marketing. In the first quarter, sales and marketing consumed just 11% of revenue.

The company focuses on individual developers and small businesses, so big enterprise customers are largely out of reach. But even so, the company sees its market opportunity growing to $195 billion by 2026. Demand for simplicity within the cloud computing infrastructure market is enormous.

DigitalOcean is valued at $4.2 billion. That's about six times revenue guidance and less than 30 times adjusted free-cash-flow guidance. Given the company's long-term growth potential and its reasonable valuation, the stock's rally to start the year could be just the beginning.