The Nasdaq Composite declined 33% in 2022, marking its worst annual performance since the Great Recession in 2008. But the technology-heavy index has mounted a spectacular rebound in 2023, soaring 44% year to date. And history says that upward momentum could continue in 2024.

Excluding 2022, the Nasdaq suffered a calendar-year decline exceeding 10% only eight times since its inception in 1971. Those events were generally followed by two strong rebound years. Specifically, the index returned an average of 16% during the year immediately following a double-digit decline and returned an average of 15% during the subsequent year.

In other words, the Nasdaq Composite should climb about 15% in 2024 if its performance aligns with the historical average. That upward momentum could push the values of Amazon (AMZN 0.81%) and Alphabet (GOOGL 0.37%) (GOOG 0.32%) above $2 trillion, meaning both companies would join a club that's currently exclusive to Apple and Microsoft.

Of course, past performance is never a guarantee of future returns, but Amazon and Alphabet are worth buying today, regardless of what happens next year. Here's why.

1. Amazon

Amazon currently has a market capitalization of $1.6 trillion. That figure would need to increase 25% over the next year to reach $2 trillion by the end of 2024.

History says that outcome is well within the realm of possibility. Amazon stock returned 82% year to date. But even if those gains fail to materialize, Amazon is still a smart long-term investment, given its strong presence in three large markets: e-commerce, digital advertising, and cloud computing.

Amazon operates the most-visited e-commerce marketplace in the world and accounts for 38% of online retail sales in the U.S., more than the next nine competitors combined. That tremendous ability to engage shoppers and source data helped Amazon become the third-largest ad tech company in the world. Additionally, Amazon Web Services (AWS) is the largest provider of cloud infrastructure and platform services (CIPS), due to the unparalleled breadth and depth of its portfolio.

That last point is especially significant. As the CIPS leader, Amazon should benefit greatly as businesses invest in artificial intelligence (AI). To quote Argus analyst Jim Kelleher, "AWS is uniquely positioned in the burgeoning AI-as-a-service market." To further reinforce that point, consultancy firm Gartner recently recognized AWS as a leader in cloud AI developer services, citing a greater ability to execute than any other vendor.

AWS is leaning into that leadership with Bedrock and CodeWhisperer. Bedrock is a cloud service that helps businesses build custom generative AI applications, and CodeWhisperer is an AI-enabled productivity tool that automates portions of the coding process to accelerate software development. Ultimately, those products could help AWS reinforce its leadership in the cloud.

Retail e-commerce sales are forecast to increase at 8% annually through 2030, digital ad spending is expected to grow at 10% annually through 2032, and the cloud computing market is projected to expand at 14% annually through 2030. In that light, Amazon has a good shot at low-double-digit revenue growth for many years to come, a reasonable estimate, given that revenue increased at 16.8% annually over the last three years.

Moreover, that estimate makes its current valuation of 2.9x sales look quite reasonable. So patient investors should feel comfortable buying a small position in this growth stock today.

2. Alphabet

Alphabet currently has a market capitalization of $1.8 trillion. That figure would need to increase 11% over the next year to reach $2 trillion by the end of 2024.

History says that outcome is plausible. Alphabet stock returned 60% year to date. But even if its market capitalization falls short of $2 trillion by the end of 2024, Alphabet is still a worthwhile long-term investment, given its strong presence in two large markets: digital advertising and cloud computing.

Alphabet subsidiary Google effectively positioned itself as the gateway to the internet. It owns six products that serve more than 2 billion users, including the most popular search engine (Google Search) and the leading web browser (Chrome). Google has a profound ability to collect consumer data, which makes the company an irreplaceable ad tech partner for many brands. Indeed, Google will account for nearly 29% of digital ad spending in 2023, more than the next two competitors combined.

Beyond advertising, Google also has a strong cloud computing business. Google Cloud Platform ranks third in CIPS revenue, behind Amazon Web Services and Microsoft Azure, but its market share increased four points to 11% in the last three years. One reason for those share gains is AI expertise. Gartner recently called Google a leader in AI research, and consultancy firm Forrester recognized its leadership in AI infrastructure services.

Alphabet is leaning into AI to drive growth across its digital advertising and cloud computing businesses. For instance, Google added generative AI capabilities to Google Ads to automate marketing workflows like media content creation and copywriting. The company also added support for generative AI to Vertex AI, its cloud platform for training machine-learning models.

Digital ad spending is forecast to increase at 10% annually through 2032, and the cloud computing market is expected to grow at 14% annually through 2030. That gives Alphabet a good shot at low-double-digit revenue growth for many years to come, a reasonable estimate, given that revenue increased at 20% annually over the last three years.

In that context, its current valuation of 6.2x sales (a discount to the three-year average of 6.4x sales) looks reasonable. Patient investors should feel comfortable buying a small position in this growth stock today.