2022 was a tough year for Amazon (AMZN -1.35%). Shares of the tech giant were down almost 50% last year, which was more than double the losses for the broad market S&P 500 Index. However, through the first few weeks of 2023, this downward trajectory has reversed, with shares of the stock up 16.8% year to date as of this writing.

The stock now has a market cap of over $1 trillion, making it the fourth most valuable U.S.-listed company. Apple, the largest company in the world by market cap, is worth $2.1 trillion.

AMZN Total Return Level Chart

AMZN Total Return Level data by YCharts

But the best may be yet to come for Amazon shareholders. Can the e-commerce and cloud leader finish 2023 as the largest company in the world by market cap and dethrone Apple?

Return to profitability

The key for Amazon in 2023 will be a return to profitability. The company has never struggled to grow its revenue given the immense size of the e-commerce and cloud-computing markets, with revenue up 685% over the last 10 years and hitting $500 billion in the last 12 months.

But profitability has been a struggle, especially recently. Operating margin was a measly 2.6% over the last 12 months after getting close to 6% before the pandemic and during a short time in 2021.

Amazon's e-commerce business got a huge bump in demand in 2020, prompting management to invest aggressively so its infrastructure could meet this demand. This required tens of billions in capital expenditures that were originally planned for a multi-year period and were hastily made to make sure Amazon customers still had a great experience with services like two-day free shipping.

However, when e-commerce growth began slowing in 2022, new capacity started to go unused, making Amazon's business less efficient and therefore less profitable.

On top of this, Amazon is now admitting it overhired, announcing an 18,000-person layoff for its corporate workforce.

It also didn't help that transportation and energy prices shot through the roof in 2021 and 2022. Amazon relies on various transportation methods for its e-commerce operations and has massive electricity/energy needs for its cloud-computing division Amazon Web Services (AWS). All these trends had a negative impact on Amazon's profit margins over the last few quarters.

In 2023, Amazon will hopefully grow into this capacity overbuild, stabilize its workforce, and see decreased energy and transportation expenses. These factors should help the company get back to 6%+ profit margins and lead to more consistent financial performance. 

Continued growth of the cloud

Amazon's e-commerce business should recover some of its profit losses in 2023. But the real value at Amazon comes from AWS. The cloud market is vast and growing quickly, estimated to grow at approximately 15% a year and hit $1.5 trillion in industry spending by 2030.

AWS is not going after this entire market as it is "just" a cloud-infrastructure provider, but with $76.5 billion in trailing 12-month revenue growing 34% year over year, it is a monster in the making. If revenue growth continues at close to this current rate, AWS' sales will get close to $100 billion in 2023. Over the long term, if it can maintain its market share and ride the tailwind of the cloud-computing transition, this business could be doing $200 billion to $300 billion in revenue or more in 2030.

AWS has fantastic profit margins as well, unlike Amazon's e-commerce operations. Over the last 12 months, operating margins at AWS were 30%. On $100 billion in sales, that equates to $30 billion in annual profits. At $200 billion in revenue, that is $60 billion in annual profits. However you run the math, AWS is vital to Amazon's business today and will be a key driver for growth this decade.

Can it dethrone Apple?

Given that it would take a more than 100% gain in just one year to get to a larger market cap than Apple, it seems fairly unlikely that Amazon will have the largest market cap in the world at the end of this year. It's not impossible if its profitability surprises to the upside, but it's a tall task nonetheless.

However, I still think Amazon's stock has solid prospects this decade. The e-commerce and cloud businesses should continue to grow, and if the company can rightsize its expenses and stabilize profit margins, the stock will likely be much higher a few years down the line, even though it is already one of the largest businesses in the world.