Food delivery is all the rage these days among both diners and investors. Apps like Grubhub's (NYSE:GRUB) Seamless and Grubhub, Uber Technologies' (NYSE:UBER) Uber Eats, DoorDash, and Postmates have taken the restaurant industry by storm.

With a convenient business model that allows customers to easily use an app or website to order from dozens of restaurants, delivery companies have broadly expanded the restaurant takeout and delivery business in the U.S. What used to be a specialized niche, for pizza delivery (from chains like Domino's Pizza) and Chinese takeout shops, has expanded to virtually every kind of restaurant concept: casual dining chains like The Cheesecake Factory, independent restaurants, fast-food chains like McDonald's (NYSE:MCD), and everything in between.

With the exception of higher-end establishments, where the decor or service makes up a significant part of the experience of eating there, restaurants have generally made their menus available on these delivery sites. They feel pressure to enlist with the apps, as consumers are increasingly going straight there to choose from a bevy of options for dinner. If these restaurants aren't included on the apps, they can't compete for that business.

As a result, business for the delivery apps is booming and sales have been skyrocketing. But as my colleague Asit Sharma has explained, that doesn't necessarily mean that these stocks are good investments. Along with growth has come intense competition as these companies duke it out for market share -- spending heavily on marketing to attract customers -- and forge exclusive partnerships with restaurant chains.

A smartphone showing a food-delivery order

Image source: Getty Images.

According to data from Second Measure, DoorDash and Grubhub are neck and neck for the market-share lead. As of June 2019, DoorDash held 33.8% share, while Grubhub owned 32.7% of the market. Uber Eats followed with 16.7%, and Postmates came in fourth with 10.8%.

However, the level of competition has weighed on profits; these rivals have been focusing on growth and customer acquisition and seem content to worry about profits later, as is typical in growth markets. Shares of Grubhub, for example, have fallen 50% over the last year as its profitability has crumbled. Grubhub's adjusted EBITDA -- its preferred way of measuring profitability -- has fallen 20% through the first half of 2019 to $105.6 million. This was true despite revenue jumping 37% to $648.8 million, showing that the company continues to capture the growth opportunity in food delivery, even as adjusted EBITDA margin fell by nearly half to 16.2%.

Uber stock has also struggled since its May initial public offering, falling by about 20% since then. While Uber Eats is a secondary business compared to the company's ridesharing operation, it's a key growth opportunity for Uber. Despite strong growth, Uber Eats has also showed signs of vulnerability lately; it ceded market share to DoorDash, and lost its exclusive partnership with McDonald's -- one of its biggest restaurant partners, if not the biggest. Prior to that McDonald's had pushed back on the arrangement to cut fees paid to Uber Eats, a sign that restaurants may hold more leverage than the delivery apps in this business. Nonetheless, Uber Eats continues to put up rapid growth, with adjusted revenue up 58%, excluding the effect of an $11 million IPO-related driver appreciation award, The service almost certainly lost money, though, considering that Uber as a whole posted an adjusted EBITDA loss of $656 million, more than doubled from the previous year.

With both Grubhub and Uber stocks sinking and industry profits reeling from excessive marketing expenses as these companies battle for new customers, it's become clear that food-delivery apps may not be the best way for investors to capitalize on the food-delivery boom. Instead, for a piece of the delivery-fueled growth, they'd be better off taking a look at the restaurant industry, the key partners benefiting from the investments and the sacrifices of delivery specialists like Grubhub, Uber Eats, and DoorDash. While several restaurant stocks have gained over the past year on investor enthusiasm for delivery, putting to rest previous worries about a restaurant recession, two stocks in particular stand out: Chipotle Mexican Grill (NYSE:CMG) and Shake Shack (NYSE:SHAK).

CMG Chart

CMG data by YCharts.

The two fast-casual stars are well-regarded for their tasty food and modern service models. Both stocks have soared this year, with Chipotle climbing a whopping 88% and Shake Shack an even more impressive 102%, as shown in the chart above.

Let's take a closer look at how these companies have capitalized on the delivery boom, and why they are so well-positioned to continue to benefit from it.

A Chipotle burrito

Image source: Chipotle.

Chipotle's on fire again

What a difference a year makes. Chipotle was basically left in the dumpster by the market following its 2015 E. coli outbreak, subsequent public-relations disaster, and sluggish recovery. The stock gave up almost two-thirds of its value over the couple of years following the foodborne-illness crisis, as Chipotle struggled to bring customers back in the door.

However, that all changed after CEO Brian Niccol -- the former CEO of Taco Bell -- took the helm in March 2018. Chipotle's shares spiked when Niccol was named the new chief, and he has clearly delivered on investor hopes; the stock has more than tripled since he was named CEO, reaching record highs. Niccol's primary strategies have been to embrace digital ordering and delivery through third-party apps, and to capitalize on the additional capacity the company installed in prior years by adding a second make line to its restaurants. Those moves have reset the company's focus, and helped turn the page on the negative media coverage that followed after the E. coli outbreak.

Chipotle's second-quarter results were its best in years. Comparable sales surged 10% on 7% comparable-transaction growth, and digital transactions essentially doubled in the quarter. Web- and app-based orders now make up 18.2% of total sales, a big step for a company whose tech infrastructure had been lagging before Niccol arrived. During the period, restaurant-level operating margins rose 120 basis points to 20.9%, and adjusted earnings per share jumped 39% to $3.99, signs that both sales and profitability are moving in the right direction.

Given those results, it's not surprising that Chipotle shares have nearly doubled this year. Investor enthusiasm for the stock has returned, and its future now looks as bright as it did before the E. coli crisis hit.

A Shake Shack burger and hot dog

Image source: Shake Shack.

Shake Shack is back

While Shake Shack didn't experience the sort of crisis that Chipotle did with its E. coli outbreak, the fast-casual burger chain still spent much of the last few years in the doldrums. Comparable sales fell in some quarters, and doubts rose about the company, prompting a long slide after its 2015 IPO. The stock became heavily shorted, as even at its low point it still carried a high valuation.

However, Shake Shack also appears to be making good on its potential: The stock has jumped 25% since the company posted blowout second-quarter results earlier this month. Like Chipotle, Shake Shack is also benefiting from digital ordering and app-based delivery. In the second quarter, the company saw 3.6% comparable-sales growth on a 1.3% increase in traffic, putting to rest previous concerns that it was losing customers. The company also raised its revenue and same-store sales guidance for the year, signs that it expects that momentum to continue.

Shake Shack doesn't break out digital sales the way Chipotle does, but CEO Randy Garutti let investors know that digital has been a significant growth driver: "Our digital channels, including delivery, were a key contributor to these results," he said. Garutti also announced a new partnership with Grubhub, adding: "To further strengthen our ongoing digital evolution, and as a part of our focus on accessibility and convenience for our guests, we're pleased to announce an integrated delivery partnership with Grubhub, which will be rolled out across the system over the remainder of this year and into early next."

With Grubhub in its corner, Shake Shack's digital sales and overall revenue are likely only to accelerate.

What makes Chipotle and Shake Shack special

Plenty of restaurant stocks have tried to catch a ride on the delivery rocket, but no others have had the level of success and blowout growth this year that Chipotle and Shake Shack have. That's because these stocks are uniquely suited to app-based delivery and to the customers who use it most.

Both companies, for example, have almost entirely eschewed drive-thru, an industry standard and the source of a majority of domestic sales for legacy fast-food chains like McDonald's. For Chipotle especially, that decision was surprising, but it now seems to be paying off. In the digital-and-delivery era, drive-thru service is mostly unnecessary -- a customer can easily and conveniently order and pay from a smartphone, then simply walk in and pick up the order when it's ready. For these chains, digital ordering and pickup/delivery is actually more efficient than drive-thru, which requires a dedicated order taker as well as an employee at the drive-thru window to handle payments and hand off orders -- not to mention the real estate devoted slowly moving around the restaurant.

In other words, with today's boom in digital ordering and delivery, the drive-thru system and the real estate necessary to make it work may be turning into a competitive disadvantage for McDonald's and its peers.

Second, Chipotle and Shake Shack both grew up with millennials, coming of age in a different era than McDonald's and the legacy fast-food chains. Not surprisingly, millennials are the biggest fans of these two fast-casual chains and, as you might expect, are the biggest users of food-delivery apps. That creates a symbiosis between chains like Chipotle and Shake Shack and delivery services like DoorDash and Grubhub, making their relationships especially valuable.

Finally, Chipotle and Shake Shack locations are most often found in cities and downtown commercial districts, not the roadside rest areas where McDonald's and its peers dominate. The density in cities naturally lends itself to delivery, as it adds efficiencies for services trying to deliver many orders in as little time as possible. In Manhattan, for example, where both Chipotle and Shake Shack have blanketed the market, it's easy to imagine a delivery person bringing multiple Chipotle or Shake Shack lunchtime orders to different floors of the same office building. For both Chipotle and Shake Shack, these lunchtime orders are a crucial driver of their business, and they dovetail perfectly with app-based delivery.

Investors seem to recognize the unique advantage that these two chains can draw from delivery, which helps explain the stocks' surge this year. But profits have not kept pace so far with the stocks' growth, and some have questioned whether their current valuation is warranted.

That's a fair debate, but what's clear is that these two companies are emerging as the big winners from the food-delivery wars. No matter which app becomes the champ, Chipotle and Shake Shack will both benefit from the increased convenience and demand for delivery that the app boom is driving. Both companies have built-in advantages across their businesses that will give them an edge over the competition as delivery goes mainstream.