When considering stocks to hold forever, focusing on growth is important, but it's equally important to understand the strengths of a company that will keep it around for decades.

The following two companies have a long record of double-digit growth that ultimately stems from a massive installed base of users relying on these companies for essential daily services.

1. Alphabet

Share prices of Alphabet (GOOG 5.46%) (GOOGL 5.53%) are up 162% over the last five years, soundly beating the average return of the major indexes. The company's lead in digital advertising, which is how it makes most of its money, has driven high double-digit growth in revenue, earnings per share, and free cash flow over the last 10 years.  

Alphabet has a lot of investments in various business opportunities, including Google Cloud, artificial intelligence (AI), and other bets it refers to as "moonshots" -- investments that may never amount to anything, but a few successful endeavors could make a difference to the long-term growth of the company.

Advertising revenue from Search and YouTube generates the bulk of the company's $289 billion in trailing revenue. Google Search, YouTube, Gmail, Google Maps, and other services are widely used, and this makes these assets valuable places for advertisers to invest in.

Google is the largest digital ad business, holding a 25% share of the market last year. The digital advertising market is expected to reach $679 billion this year, according to Statista, and is projected to keep growing. YouTube is an increasingly valuable asset, as the user base is expected to reach 1.1 billion users by 2028, which will likely keep it in the lead as the most-watched video-streaming platform.  

Its dominance in a lucrative digital ad market translates to a growing stream of $71 billion in trailing free cash flow. That is ample resources to invest in AI technology that makes its services and apps more useful to keep people locked into the Google ecosystem. 

A forward price-to-earnings (P/E) ratio of 25 is an attractive valuation for the stock right now. Investors should see more gains from here as the advertising market recovers. Alphabet will likely see its revenue and earnings growth accelerate back to double-digit rates as the outlook for the economy improves and advertisers increase their spending. For what it's worth, Wall Street analysts currently estimate earnings to grow at an annualized rate of 18% over the next five years. That's enough growth to potentially double the stock price.

2. Microsoft

Shares of Microsoft (MSFT 1.28%) have delivered a market-beating return of 214% over the last five years, enough to turn a $1,000 investment into $3,100. Most of that return was driven by Microsoft's earnings per share doubling over that period, and the good news is that there are still plenty of opportunities for more profitable growth from the software giant. 

It would be tough for the world to remain productive without Microsoft. The software leader is gaining market share with many products right now, including business applications and cloud services, and is about to make a huge leap ahead in the video game industry with the recently completed monster acquisition of Activision Blizzard.

Microsoft has reported slowing growth this year as macroeconomic headwinds force businesses to tighten spending. However, it will recover, as the number of devices running Windows 11 doubled over the last year, while commercial deployments are also growing worldwide. 

The growth in Windows should lead to growing revenue, as users spend on software and gaming. New AI tools for Microsoft's software applications should drive long-term demand, while Activision Blizzard positions the Xbox owner for growth with its Xbox Game Pass subscription service and mobile gaming, which could surpass $200 billion in the next decade. 

Microsoft is another cash machine that will be rewarding investors for many years. The business generated $59 billion of free cash flow on $211 billion in trailing revenue.

The stock's forward P/E of 30 is not cheap but hardly expensive for a business that is so deeply entrenched in work and play for millions of customers and producing tremendous cash flows to reinvest in future opportunities.