Palantir (PLTR 3.22%) and SEMrush (SEMR 2.86%) haven't been the best-performing stocks in 2021. SEMrush went public in late March, and it has already fallen over 40% from its all-time high. Palantir is down 20% year to date and nearly 60% from its high mark.

But just because they've fallen in recent months doesn't mean these companies are bad investments. Both stocks have incredible potential and sustainable advantages that should allow them to thrive long term. Here's why I think these two surefire stocks could surge over the next decade.

People sitting at a table with a lightbulb in focus.

uImage source: Getty Images.

Palantir: A new way to look at data

In a world where not all data can fit neatly in a spreadsheet for analysis, unstructured data often ends up ignored. Even when the information within is incredibly important, companies and government entities may not have the capabilities to utilize all of their data -- this is where Palantir steps in. 

Palantir started as a company working solely with the U.S. government to provide software and data analysis for counterterrorism efforts. Gotham -- its software platform that extracts insights and patterns from data -- helped the U.S. government find connections it may have never discovered otherwise. The company has since expanded its capabilities to the commercial sector with its second software solution, Foundry. Despite Palantir's original focus on government contracts, Foundry has seen incredible commercial adoption with the number of private sector customers as of Sept. 30 up 135% since the start of the year.

In the third quarter, Palantir only closed on 54 new contracts, yet 51 of them were worth at least $5 million. The company spent over $153 million on sales and marketing to attract the 34 net new customers it signed on during the quarter, but this line item declined substantially from $335 million in the prior-year period.

There are two risks with Palantir, the first being its bottom line. The company reported a net loss of $102 million in the latest quarter, but like its spending, this figure improved from an $853 million loss last year. Palantir's path to profitability is clear: Its brand continues to gain traction with revenue growing quickly despite reductions to sales and marketing.

Otherwise, the second risk investors should be aware of is Palantir's high valuation. The stock trades at 24 times sales, far higher than other government-focused contractors like Booz Allen Hamilton and Leidos, which both trade around one times sales. 

However, Palantir's continued success in both the public and private sectors give it the potential to grow into this valuation with market-beating returns for long-term investors.

SEMrush: A marketer's dream

Marketers don't want to go all in on a single advertising strategy, because it might not be as effective at reaching their target audience as they hope. As a result, they turn to platforms of solutions that allow them to see various aspects of their approach and move forward from there. SEMrush helps them do that. 

SEMrush is a visibility management tool that allows marketers to gather insights and apply them to their marketing campaigns. The company's key advantage is its wide offering: It offers tools for nearly every major category of marketing technology. The company operates in 17 of these categories, and management believes its tools are leaders in 12 of them. This makes it easy for advertisers to monitor all of their strategies in one place rather than juggling offerings from multiple providers.

This competitive advantage is an important one. Most of the competition is made up of rivals who dabble in just one or two categories, and none come close to the broad-based reach SEMrush enjoys. This is why SEMrush has established a dominant position in the industry with over 79,000 customers in 146 countries.

The company is managing the balance of profitability and growth extremely well. Management expects to have delivered a five-year compound annual growth rate of 50% by the end of this year, yet it is near breakeven. SEMrush reported a small loss in the third quarter, representing about 1% of its top line. And year to date, it has generated almost $17 million of free cash flow, showing how well it can grow while keeping its bottom line in check. 

Trading at 15 times sales, SEMrush also commands a hefty premium, but this is yet another case where long-term investors can feel confident paying up for a high-quality business. The company is well-positioned to claim a growing share of its existing $13 billion global market opportunity, and that number is expected to rise to $20 billion going forward.