Bear markets can test an investor's patience. The average bear market lasts about nine and a half months, so we probably still have a long way to go. In times like this, many investors fall into the trap of not wanting to lose more money, so they quit buying.

However, this is a huge mistake.

Buying during bear markets could set the stage for massive returns, as investors are purchasing assets that are cheaper than they'd be worth if the economic outlook weren't so grim. With that in mind, I've pinpointed two stocks I think investors should buy in the current bear market: Twilio (TWLO -0.28%) and Cloudflare (NET 0.96%). Both businesses were caught up in the stock market euphoria last year and have tumbled to a valuation that makes them attractive.  

Growth is just beginning

A key point for both businesses is that their product rollout is far from complete.

Twilio's software allows its clients to communicate better with its customers by using Twilio's application program interfaces (APIs). With these APIs, customers with no coding experience can easily create programs that send text message reminders for appointments, tailor marketing emails, or automatically set up video conferences.

Cloudflare is on a mission to build a better internet and is doing it through hundreds of data centers across the globe. As a result, clients who host their websites on Cloudflare no longer need to maintain expensive networking equipment. Instead, Cloudflare's team takes care of that while providing best-in-class cybersecurity for their websites. With Cloudflare, clients have ensured their website is faster and more secure than if they did it in-house.

Neither Twilio nor Cloudflare have fully captured their intended audiences, which for Twilio is every company that engages its customers through communication, and for Cloudflare, it's every company that hosts a website. However, each is posting solid growth and is predicting more of the same.

Solid growth with more on the horizon

With Twilio, investors need to be aware that the company has made several acquisitions to become a go-to solution for customer communication. For example, Twilio acquired Zipwhip (a provider of toll-free messaging) and Segment (a customer data platform) over the past three years. These acquisitions weren't cheap, with Zipwhip costing $850 million and Segment totaling $3.2 billion. However, Twilio mostly paid for these acquisitions through issuing stock, which is why the business has a strong balance sheet of $4.391 billion in cash and short-term investments versus $986 million in debt.

Naturally, these acquisitions affect its financials, as a business can show impressive revenue growth if it continues purchasing other companies. To assist with better business analysis, Twilio's management also reports organic growth, which excludes acquisitions made in the past 12 months. In the second quarter, Twilio's organic revenue rose 33% year over year to $862 million.  

This level isn't the peak for Twilio, as CEO and co-founder Jeff Lawson projects Twilio will grow organic revenue annually by at least 30% through 2024. Despite strong revenue growth, Twilio has never been free cash flow positive during its time as a public company. This unprofitability has driven many investors away, but Lawson also noted Twilio will produce non-GAAP operating profits starting with 2023 full year results.

Twilio still has plenty of growth ahead, and with profitability on the horizon, the stock's prospects are looking up.

Cloudflare is a growth machine

Cloudflare continued its trend of essentially 50% year-over-year revenue growth in Q2, just as it has since going public.

NET Revenue (Quarterly YoY Growth) Chart

NET Revenue (Quarterly YoY Growth) data by YCharts

It's rare for a company to maintain 50% revenue growth for three years, but Cloudflare has accomplished that feat. Although Wall Street analysts project that 2023's revenue growth will only be 36%, this metric may accelerate as more customers recognize the benefits of using Cloudflare.

One knock against both companies is their unprofitability. Twilio has never produced profits in its life as a public company but plans to produce non-GAAP (adjusted) operating profits by 2023. To do this, it cut about 11% of its workforce, a move the market applauded by sending the stock up 10%.

As for Cloudflare, it's steadily marched toward profitability over its life as a public company and even projects it will make about $0.03 to $0.04 in earnings per share (EPS) this year. 

Many companies say they have a "path to profitability," but Twilio and Cloudflare are executing on that vision.

As for their stocks, one is cheaply valued while the other commands a steep price. Cloudflare trades at an expensive 22 times sales, a level reserved for companies with substantial growth ahead. For example, if Cloudflare achieves its long-term model of 20% non-GAAP operating margins, its stock is trading for 110 times operating profit. Remember that this number doesn't include taxes or stock-based compensation, so its true, hypothetical, fully profitable valuation is much higher.

For Cloudflare to bring this valuation down, it will need to continue growing its sales for many years. But with its $135 billion market opportunity by 2024, Cloudflare has a big enough runway that the price tag shouldn't stop investors from buying the stock.

Twilio's valuation story is entirely different than Cloudflare's -- it's a very cheap stock. It trades at 3.6 times sales, around the same level as legacy tech players Oracle (3.8 times sales) and Cisco Systems (3.3 times sales). At this level, valuation isn't a concern, as Twilio's stock is cheap.

Even during a bear market, both of these stocks are worth a look because the economic outlook affects their valuations. Once the economy ramps back up again, these businesses will see another growth push alongside their usual demand. While I don't know when this recovery will be, I'm confident that the market opportunity for these two companies is large enough that the stocks can be held for over five years without needing to be sold.