Investing in the stock market can be a great way to grow your wealth over the long term, but the past year has presented challenges for investors. Major indices, such as the S&P 500, posted double-digit losses in 2022 due to macroeconomic challenges like rising interest rates and surging inflation.

Despite these challenges, it's important to remember that the stock market has historically provided solid returns in the long run. Low prices are a problem only if you're selling your shares. Active buyers see tremendous buying opportunities in a temporary downturn.

Here are two of the best stocks to buy now in the final weeks of December, each playing a specific role in your well-diversified portfolio. Separately or together, these stocks have significant upside potential in 2023 and beyond.

Whether you have $1,000 or a larger sum to invest, now may be a good time to consider adding one or both of these top stocks to your portfolio without breaking the bank.

1. The exciting hypergrowth stock: Roku

Roku (ROKU 1.00%) has successfully carved out a niche in the rapidly expanding streaming-media market. The company's line of streaming devices, including its popular Roku streaming sticks and boxes, allow users to access a wide range of streaming content from popular services such as Netflix, Disney+, and Amazon Prime. Roku's software also powers the media-viewing systems of many smart television sets -- a highly profitable business for Roku with generous royalty revenue and no hardware costs.

In addition to its hardware products, the company operates its own streaming platform called The Roku Channel, which features free, ad-supported content from a variety of sources. Advertising has grown into a helpful secondary revenue stream, though Roku's stock has fallen hard in 2022 due to weak sales across the digital-advertising market.

Roku's growth has been fueled by the increasing popularity of streaming media and the shift away from traditional cable and satellite TV. The company also benefits from strong partnerships with major content providers, which has helped it to attract and retain a large user base. In addition, Roku has a strong track record of innovation, consistently releasing new and improved products to meet the evolving needs of its customers.

Overall, Roku's combination of a strong brand, innovative products, and a growing market make it a fast-growing and exciting company for investors. However, market makers have turned their backs on Roku in 2022 because of the aforementioned slowdown in ad sales.

As a result, on Thursday, Dec. 22, Roku's stock had fallen 81% in 52 weeks. That price drop has opened a tremendous buying window.

Roku's stock trades at just two times trailing sales and three times the company's cash reserves. These valuation ratios would be reasonable for a mature value stock in sleepy markets, such as big-box retailers, consumer-goods staples, or large-scale manufacturing. But Roku's trailing sales and earnings are skyrocketing at a compound annual growth rate (CAGR) of more than 40% over the last five years.

Despite the reported ad-sales issue, Roku still reported 15% year-over-year growth in platform revenues in the third quarter. This division includes advertising revenues, as well as content distribution agreements, subscription fees, and service-branded buttons on Roku's remote controls.

The impact of softer ad sales is nearly undetectable amid the many healthy growth sources included in that bundle. Yet that's the issue that drove stock prices lower this year.

Roku's stock is ridiculously cheap right now, for reasons that don't really move the company's revenue needle yet. The company's advertising is still in its infancy, and its long-term success won't suffer much from a temporary slowdown in the early going. If you want a spring-loaded growth stock for 2023, Roku looks like your best bet.

2. The generous dividend payer: Texas Instruments

Semiconductor-veteran Texas Instruments (TXN 0.96%) has a long history of paying ever-increasing dividends to its shareholders. The company's wide variety of mixed-signal and analog chips targets an equally broad range of target markets, insulating TI from swings in any particular sector.

This gigantic cash machine loves sending money back into shareholders' pockets. Over the last four quarters, TI has spent $2.7 billion on share buybacks and $4.2 billion on dividend checks.

One might think that the company's cash coffers would run dry from all this shareholder-friendly spending in the midst of a macroeconomic crisis, especially since TI is making heavy investments in chip-manufacturing infrastructure at the same time. One would be wrong, though.

Despite surging capital expenses, Texas Instruments generates enough cash profits to finance its shareholder cash returns, and then some:

TXN Cash Dividend Payout Ratio Chart

TXN Cash Dividend Payout Ratio data by YCharts.

The company currently funnels 72% of its free cash flow into dividend payments. That's a 20-year high but still leaves ample room for opportunistic buybacks and future dividend increases.

Texas Instruments can weather the wildest swings the economy might throw at it, raising dividend payouts with a smile and preparing for higher chip demand in the future. At the same time, the stock price is down by 10% in 2022, and the effective dividend yield stands at a generous 2.9%. This is a stock you can buy today and leave untouched for years or even decades to come, quietly generating rising dividend income for the long haul.