Technology stocks are having a forgettable 2022, as the 28% decline in the NASDAQ-100 Technology Sector index shows, with investors choosing to dump high-growth, richly valued companies amid surging inflation, geopolitical instability in Europe, and rate hikes by the Federal Reserve.

However, the steep decline in technology stocks so far this year means that investors have an opportunity to buy shares of companies that are shaping our future at cheap valuations. Nvidia (NVDA -2.48%) and Apple (AAPL -2.19%) are two such tech stocks that are worth buying following pullbacks, as they are on track to win big from lucrative trends.

Let's look at the reasons why buying these two stocks right now could help set up investors' portfolios for long-term gains.

A person holds a smartphone.

Image source: Getty Images.

1. Nvidia

With shares down nearly 40% in 2022, Nvidia investors were hoping for some good news from the company's fiscal 2023 first-quarter results, covering the three months ended May 1. But the graphics specialist delivered muted guidance on account of supply chain problems exacerbated by COVID-related lockdowns in China, as well as the soft demand for its gaming chips in parts of Europe.

The chip giant expects the current quarter's revenue to land at $8.1 billion at the midpoint of its guidance range. That's down from $8.29 billion in Q1 and accounts for a $500 million top-line hit thanks to the loss of sales in Russia and China, and COVID lockdowns in China. Wall Street was looking for $8.54 billion in revenue from Nvidia this quarter, and the company would have easily cleared that mark had it not been for the macro factors discussed above.

The muted guidance may not be confidence-inspiring for investors in the near term, but it is worth noting that Nvidia says it is on track to deliver impressive year-over-year revenue growth of 24% despite the headwinds. What's more, its earnings are expected to grow at an annual pace of 32% for the next five years.

A closer look at Nvidia's key growth hot spots tells us just why the company is expected to clock such impressive growth. The data center business, for example, is turning out to be a massive catalyst for Nvidia. The company saw an 83% year-over-year increase in revenue from this segment last quarter to $3.75 billion, accounting for 45% of the top line.

This terrific growth was driven by the healthy demand for Nvidia's graphics processing units (GPUs) by hyperscale cloud customers. Nvidia management expects the data center momentum to continue in the long run, which isn't surprising as the company is pushing the envelope to ensure its dominance in this fast-growing space.

Nvidia claims that its new H100 data center GPU provides a big jump in performance over the existing A100 chip and should prove ideal for tackling intensive artificial intelligence (AI) workloads. Nvidia says it is already "working with leading server makers and hyperscale customers to qualify and ramp H100." More importantly, the company will double down on its data center opportunity with the Grace data center central processing unit (CPU) that's set to be launched in the first half of 2023.

Nvidia recently announced that several server OEMs (original equipment manufacturers) such as Foxconn, ASUS, Gigabyte, and others will be manufacturing servers using Grace. As such, Nvidia looks set to make a solid entrance into a market that has historically been dominated by its rivals.

And, as the data center is just one of the many catalysts for Nvidia, it wouldn't be surprising to see the company sustain its impressive growth in 2022 and beyond. That's why investors looking to buy a hot tech stock should take a closer look at Nvidia, as it is trading at 48 times earnings, which is lower than its five-year average multiple of 58.

2. Apple

Apple stock is down 19% so far this year and trading at 23 times earnings, compared to last year's multiple of 31. This relatively cheap valuation helps make Apple a top stock to buy. Here are a few other things that have me excited about the stock.

The arrival of 5G smartphones has turned out to be a huge growth driver for Apple, with the company cornering a nice chunk of this fast-growing market and also enjoying robust pricing power. With some expecting sales of 5G smartphones to grow at an annual rate of 124% through 2025, Apple could witness healthy iPhone sales growth for the next few years.

Apple is also reportedly looking to tap emerging tech trends for growth. Reports indicate that the company is close to launching its augmented reality/virtual reality-enabled headset. The company is expected to launch its headset sometime next year, and that could open the gates for Apple to take advantage of a market that's expected to grow substantially in the long run.

Apple is recording impressive growth in its services business. Its services revenue was up 17% year-over-year in the second quarter of fiscal 2022, outpacing the company's overall top-line growth of 9%. It is also worth noting that Apple's services business had a gross margin of 72.6% last fiscal quarter, compared to an overall gross margin of 43.7%.

Services revenue currently accounts for just under 18% of total revenue, but could become much bigger in the long run as the company grows these profitable offerings.

There are multiple reasons why Apple seems set for long-term growth, which makes this tech stock worth buying right now.