Last year was plagued by declines in the stock market, with numerous companies suffering losses as they faced macroeconomic headwinds. Despite its leading market share in multiple industries, Amazon's (AMZN -2.56%) stock was not left unscathed, falling 46% over the past 12 months. 

The sell-off in 2022 has left many prospective investors wondering if now is the right time to buy, with shares in some of the world's most valuable companies starting the new year on sale.

However, working out whether or not Amazon shares are a buy in 2023 is complex. The company had a more challenging year than most, with significant hits to its e-commerce business and free cash flow. Meanwhile, recent moves suggest Amazon is preparing for more declines amid a looming recession. So, is Amazon stock a buy in 2023? Let's find out. 

Preparing for a recession 

On Jan. 5, Amazon CEO Andy Jassy revealed the company had increased its planned employee layoffs from 10,000 to 18,000. The decision comes after other cost-cutting measures in 2022, such as closing or canceling construction on dozens of warehouses, putting a freeze on hiring, and shuttering its telehealth brand Amazon Care. 

Amazon is not alone in slashing its budgets. Other big names in tech, like Microsoft and Salesforce, have also announced plans to pare down staff, while Alphabet CEO Sundar Pichai began clamping down on companywide costs in September 2022. It is encouraging that Amazon isn't alone in its troubles. However, the company hasn't been able to overcome the last year as well as its peers. 

In the same period that Amazon's stock has fallen 46%, Microsoft and Alphabet shares have tumbled 28% and 35%. When looking at the companies' free cash flow as of Sept. 30, Amazon's came in at a negative $26.3 billion, while Microsoft and Alphabet reported between $62.5 billion and $63.3 billion.

In addition to budget cuts, Amazon is preparing itself for further declines in 2023 by taking out a short-term $8 billion loan in the first week of January. The company ended its last quarter with about $35 billion in cash and $59 billion in long-term debt, making the comparatively small loan of $8 billion seemingly unnecessary.

However, after a year of suffering significant losses in its e-commerce business, reporting operating losses of $2.9 billion between its North American and International segments in third-quarter 2022, Amazon seems to be quickly burning through cash. As a result, the loan could help the company move past potential roadblocks in the coming months. 

Amazon stock is a long-term hold 

Last year was one to forget for Amazon, but all hope is not lost. The company continues to have leading market shares in multiple industries that still have plenty of room for growth in the long term.

After a surge in the e-commerce industry throughout 2020 and 2021, when the pandemic made online shopping unavoidable, 2022 told a different story. Comparisons against the boosted year-ago period and economic factors led to declines in the industry and losses for Amazon. However, a poor economic climate won't last forever, and Amazon's 37.8% market share in the industry will likely pay off in the end.

According to Grand View Research, the e-commerce market was worth $9.09 trillion in 2019 and will grow at a compound annual growth rate (CAGR) of 14.7% until at least 2027. And Amazon is in a prime position to profit from that growth. 

Moreover, the most attractive part of Amazon's business is its cloud-computing platform, Amazon Web Services (AWS). As of Q3 2022, the platform had a leading 34% market share in the booming industry. The cloud computing market was worth $368.97 billion in 2021 and will see a CAGR of 15.7% until 2030. And Amazon is already profiting from the industry's growth, with AWS revenue rising 27% year over year to $20.5 billion in Q3 2022 and bringing in 100% of the company's operating income.

Despite a promising long-term outlook, Amazon stock is tricky to recommend in 2023. Its price-to-earnings ratio of 80 suggests its stock is still expensive against its financials.

Ultimately, it's best to proceed with caution when considering an investment in Amazon. Either prepare to hold the stock for well over five years, or look at more attractive buys, such as Alphabet and Microsoft, which are trading at 17.6 and 24.5 times their earnings, respectively.