You'll struggle to find better consumer-facing companies than Apple (AAPL 0.07%) and Costco Wholesale (COST 0.23%).

These two companies have built massive, loyal customer followings, and their stocks have delivered life-changing investment returns over the years on their way to becoming two of the world's largest companies by market cap.

While both stocks may struggle to deliver the same level of returns they did in their earlier years, both can still be long-term winners in a stock portfolio. That said, you shouldn't just buy at any price, especially for maturing companies like Apple and Costco Wholesale.

So, which is the better buy now? Here is what you need to know.

Close-up of an Apple iPhone in someone's hand.

Image source: Getty Images.

Both companies still have some juice left

Apple is a leading smartphone and personal electronics company, renowned for its iOS ecosystem, which has over 2.35 billion active users worldwide. Costco is a leading membership-only big-box warehouse retailer, where members can buy a variety of goods, often sold in bulk quantities.

Both companies are well-established in their core businesses, but continue to demonstrate the ability to grow, albeit at a slower pace than in the past. With annual revenue in the billions, it's challenging to maintain high growth rates, but growth remains.

Apple continues to slowly increase its user base while also growing by offering a variety of subscription services to its users. Service revenue totaled nearly $53 billion through the first half of this year, up 12.7% year over year.

For Costco, there is some growth in merchandise sales as inflation lifts prices higher, but its core growth engine is membership growth. Costco's paid memberships increased by 6.8% year over year in the latest quarter to 79.6 million. Membership dues contribute the majority of the company's profits.

Overall, both companies have solid -- if not gigantic -- growth prospects. Analysts estimate that Apple will grow its earnings by an average of 10.6% annually over the long term, compared to about 9% for Costco.

The two stocks have performed remarkably similarly over the past decade

Despite these companies operating very different businesses, their stock prices have performed similarly over the past 10 years. From a share price standpoint, Costco and Apple have generated nearly identical annualized returns over the past decade, and both have vastly outperformed the S&P 500.

AAPL Chart

AAPL data by YCharts

Both companies pay small-yielding regular dividends, too. Apple has paid and raised its dividend for 12 consecutive years, while Costco has done the same for 20 years. Their dividend yields are similar, ranging from about 0.4% to 0.5%. However, Costco occasionally pays special dividends, giving it a slight edge for investors who look for dividend income.

But one is the better buy right now

Analysts currently expect a little more growth from Apple moving forward than from Costco, but it may also be a bit riskier than Costco.

Apple has struggled to integrate artificial intelligence (AI) features into its iOS devices. The company has had to revisit the drawing board. However, Apple users tend to be quite loyal, and the iOS ecosystem is very sticky. So, while it may be too soon to panic, Apple needs to get AI right at some point, or it could face disruptive threats from competitors.

Despite this, Apple is still the better stock to buy now.

Why? Costco's stock returns over the past decade have been driven in part by valuation expansion. In other words, Costco's stock price has expanded faster than its profits. Today, Costco Wholesale trades at a price-to-earnings (P/E) ratio of nearly 54. That's far too high for a business expected to grow earnings at a 9% annualized pace moving forward.

Apple isn't a bargain at a P/E ratio of 33, but it is far more attractive, assuming the company delivers double-digit earnings growth as expected. Apple also repurchases massive amounts of its stock, which should help drive earnings growth, even as the company navigates its AI learning curve.