One of the central themes of the U.S. economy recently has been the soaring value of homes. According to data from Redfin, a real estate brokerage, the median sale price of homes sold in October jumped 13.2% from a year ago. October was actually the 15th straight month of double-digit gains. 

For investors looking to play this trend in 2022, two massive retailers come to mind. Here's why Home Depot (HD -1.77%) and Lowe's (LOW -1.40%) are stocks to consider if you want to benefit from rising home prices. 

Couple holding keys to their new home.

Image source: Getty Images.

Why are housing prices going up? 

A little bit of background on the current real estate situation may provide readers with some context. I think there are three main reasons for soaring home prices. 

First, the pandemic is causing many people to reconsider their living situations. Termed the "Great Reshuffling" by Zillow, Americans, now armed with greater flexibility thanks to the popularity of remote work, are eyeing lower-cost cities as places to live. Why pay astronomical living costs in places like New York City or San Francisco when many companies are letting employees work from anywhere? A bigger house with a home office can be purchased for a more affordable price in less dense metropolitan areas. 

Second, interest rates are still at historic lows. The Federal Reserve pumped unprecedented amounts of stimulus into the economy to support individuals and businesses during this difficult period, adding downward pressure to rates. Although the Fed's latest meeting revealed plans to tighten monetary policy and raise rates three times next year, the average 30-year, fixed-rate mortgage in the U.S. has been falling consistently over the past 40 years and is still at record lows. 

Finally, there's quite simply a housing shortage right now. Even before the pandemic, the pace of home construction since the Great Recession hasn't been adequate. As a result, it is estimated that the U.S. is short 5 million single-family homes. This is a problem that will likely persist for many more years. It's no wonder prices are rising so much. 

How Home Depot and Lowe's benefit 

During the Gold Rush of the late 1840s, it wasn't a miner who became the first millionaire. Instead, Samuel Brannan, who sold shovels, picks, and pans, was known as the richest man in California at the time. Businesses that sell goods and services catering to the actual end product are known in the investment world as "pick-and-shovel plays." With higher housing prices, people are increasingly viewing renovation projects as investments in their properties -- and Home Depot and Lowe's are that pick-and-shovel opportunity right now. 

The U.S. is still going to be dealing with the three industry tailwinds (Americans moving, low borrowing costs, and short housing supply) in 2022, setting these home-improvement giants up for continued success. Wall Street analysts are forecasting fiscal 2022 sales of $154 billion and $97 billion for Home Depot and Lowe's, respectively. While that would be up just slightly vs. the current fiscal year, keep in mind that comparisons next year get difficult as these two businesses have experienced a surge in demand since the pandemic started. 

What makes these two companies special is that they serve both do-it-yourself and professional customers. The former experienced strong growth at the start of the pandemic, but the latter -- which includes contractors, plumbers, and electricians -- have had their moment to shine in recent quarters as homeowners grow comfortable with allowing strangers into their homes for bigger projects. 

Home Depot generates 45% of its total sales from professionals, a serious advantage over Lowe's 25%. Additionally, Home Depot's return on invested capital of 44% crushes Lowe's 30% return thanks to having more business from these higher-spending, stickier customers. 

Based on their price-to-earnings (P/E) ratios, both stocks trade at reasonable valuations today -- 27 for Home Depot and 22 for Lowe's. That's below the broader S&P 500's P/E ratio of 29. Yet, in my opinion, these companies are of higher quality than the average business in the large index. This bodes well for these stocks from a valuation perspective. 

Home Depot and Lowe's are two great businesses that have been doing quite well during the pandemic -- and because of some powerful industry trends, I believe this momentum will carry over into 2022. If you want to play the strong housing market, these stocks are no-brainers right now.