Buying a cup of coffee every morning adds up. And if you’re going to the same place every day for your caffeine fill, you should be getting more than just that. Your coffee shop should reward your loyal patronage and in turn, ensure that you keep coming back.

The logic for launching a rewards program is simple and it works wonders for any business with a consistent product, devoted fanbase, and thoughtful customer service. In fact, it reinforces all of those traits.

Coffee businesses—from global brands with their own apps to local shops slinging house-baked pastries—are the perfect example of how membership programs can boost sales and build loyalty. Let’s take a look.

Loyalty & Rewards at Starbucks, Dunkin’, and Panera

There’s no cost to becoming a Starbucks Rewards member. You simply opt-in, earn Stars as you spend, then trade those Stars in for Rewards ranging from free customizations on espresso drinks to a bag of beans to take home. Furthermore, a membership promises exclusive benefits such as refills at no charge and opportunities to participate in challenges that allow you to earn more Stars when you buy certain items within a specified time frame. And as you rack up Stars, you can level up from Green status to Gold, which delivers bigger discounts and better freebies. See what they’re doing here? By gamifying the customer experience, Starbucks keeps you engaged and purchasing, all while giving you more bang for your buck. Once you’re an active member of the Rewards program, why would you buy your morning cup of joe elsewhere? You’re hooked.

Dunkin’ Perks work similarly. For every $1 spent, members earn five points, and every 200 points gets you a free beverage. All members receive a complimentary drink on their birthday and an immediate 200 points upon signing up.

Panera recently launched a different style of loyalty program powered by subscriptions. Members of MyPanera+ Coffee pay $8.99 a month for unlimited free coffee. They lure you in with a month of unlimited coffee for free. After that, you can do the math on how much you saved, compare it to $8.99/mo, and recognize that price as much lower than what you were spending before.

That’s how the big brands do things, but what about the smaller shops?

Punch Cards and Text-Based Membership Programs

Enter the old-school loyalty punch card. You become a patron of a coffee shop on your first visit—maybe you just moved to the neighborhood or stumbled upon it near your office—but you become a member when you ask for (or are handed) a punch card.

Every time you buy a cup, the barista makes a punch in your paper card, which you keep in your wallet. Once you’ve bought ten coffees, the next one’s free, and it’s time to get a new card. Whether you know it’s coming or you’re pleasantly surprised when it happens, that morning your cup is free is going to be a good day. And so the cycle of loyalty begins.

With the rise of Apple Pay and contactless card readers, many consumers have transitioned over to a digital wallet. Lighter pockets, less waste, and a more seamless checkout experience make this a meaningful improvement. It’s also spawned a new frontier for loyalty technology, where business owners can use products like Square to design membership programs based on their specific goals, like increased daily visits or more spend per customer. All patrons have to do is enter their phone number while checking out in order to rack up points for benefits. In turn, they’ll receive texts that notify them of earned rewards.

Coffee is a daily ritual for many, not to mention caffeine is addictive, which makes those in the business of brewing cups particularly well-suited for launching membership programs. And yet memberships work on all scales and in so many ways, whether you’re keen on building an audience for your farm stand or hoping to drive up revenue up for your fast-growing canned wine company. The math is simple: the more you give, the more you get.