No. 73Backend8 min read2,059 words
How to build a membership site: people keep paying for
How to build a membership site that renews: the MVP scope, Stripe billing synced by webhooks, leak-proof content gating, dunning, and the stack we use.
- Written by
- Lazy Devs
- Published
- Updated
- Sources
- Cited inline

Key takeaways · 05
The short version
- 01A membership site MVP needs sign-up and login, one paid plan, a gated members area, the content itself and self-serve cancellation. Tiers, trials, coupons and community can wait.
- 02Access must follow subscription status, kept in sync by payment webhooks. Checking only at checkout gives churned members free access and locks out people whose renewals succeeded late.
- 03Gate content on the server and serve files through short-lived signed URLs. Hiding a button in the browser does not protect a video or PDF at a public URL.
- 04Failed card payments are routine, so automated retries and payment-failed emails (dunning) are part of the MVP, not a later optimisation.
- 05Make cancelling as easy as joining. Several jurisdictions regulate automatic renewals, and hidden cancel flows create chargebacks and complaints.
On this page · 11
To build a membership site, you need five things: sign-up and login, a paid plan billed through a provider like Stripe, a members area that only active members can reach, the content itself, and a self-serve way to cancel. The hard part is keeping access exactly in sync with billing over months of renewals, failed cards and cancellations, so that paying members always get in and lapsed ones do not.
Most membership sites are easy to launch and surprisingly hard to keep working. The login page is the easy part. The thing that pays your bills, a member logging in months later and still getting exactly what they paid for, is where the real work hides. This guide covers what to build first, what to skip and the details that decide whether people renew or quietly churn.
What a membership site is, and the one job it has to do
A membership site sells access. People pay, usually monthly or yearly, and in exchange they get something gated: courses, a community, premium articles, downloads, live sessions or a mix. That covers everything from a paid newsletter to a professional association or a creator community.
Strip away the marketing pages and the core job is this: the right person sees the right content, and when they stop paying, they stop seeing it. Get it wrong in either direction and you lose money. Leak access and you give the product away. Cut off someone who paid and you get an angry customer and possibly a chargeback.
This guide is for founders selling access to content or a community. If your members log in to use software, you are closer to building a SaaS product and the priorities shift. And if your content is mainly structured courses with video, our guide to building an online course platform goes deeper on video and lesson progress.
The same model shows up in fitness studios, coaching programmes and paid communities; our guide to web apps for fitness and wellness covers the industry-specific parts.
The membership site MVP feature set
The trap is building a "platform". You do not need one. You need the shortest path from stranger to paying member who can reach what they bought.
Build first
- Sign-up and login. Email and password or magic links, through a hosted auth provider or a well-maintained library. Do not roll your own session handling.
- One paid plan. Monthly and yearly prices for a single tier is fine. Resist multiple tiers for now.
- A members area that shows gated content only to active members.
- The content itself, even if it is just a list of lessons or articles behind the gate.
- Billing self-service. Members update their card, see invoices and cancel without emailing you.
- Lifecycle emails. Welcome, receipt, payment failed, cancelled and renewing soon.
- A small admin area. Look up a member, see their status, grant access, issue a refund.
Push to later
Multiple tiers, free trials, coupons, community and comments, drip scheduling (releasing content week by week), group or team memberships and a mobile app. Each is a real feature with real edge cases, and they belong in phase two once the first version is earning.
The honest test for the MVP: can a member pay you and reach what they bought without a human in the loop, and leave the same way? If yes, ship it.
Keeping access in sync with billing
This is the most common place homegrown membership sites quietly lose revenue.
A card fails. A subscription is cancelled, refunded, paused or switched to a different plan. Each event has to change the member's access correctly, and the payment provider tells you through webhooks, background notifications sent to your server, not through your UI. Stripe documents the events a subscription integration should handle, and your code must cope with them arriving late, twice or out of order.
The pattern that works:
- Store a membership row per member, mirroring the subscription's status and the end of the paid period.
- Update it only from verified webhook events, recording each event ID so a duplicate does nothing.
- When an event arrives, fetch the latest subscription from the API rather than trusting the event's order.
- Run a scheduled reconciliation job that compares your table with the provider and fixes any drift.
Subscription states and what they should mean for access
Stripe subscriptions move through a defined set of statuses. Decide up front what each means for your members:
| Status | What happened | Recommended access |
|---|---|---|
trialing | Member is in a free trial | Full access until the trial ends |
active | Paid and current | Full access |
past_due | A renewal payment failed and is being retried | Keep access for a short grace period, and show a banner to update the card |
unpaid | Retries are exhausted, subscription kept open | Remove access, keep the account |
canceled | Subscription has ended, either at period end or immediately | Remove access, keep the account and offer a way back |
incomplete | First payment needs action or failed | No access yet |
paused | A free trial ended without a payment method | No access until a card is added |
A member who cancels mid-month has usually paid until the period ends. In that case Stripe keeps the subscription active with cancel_at_period_end set to true, and only moves it to canceled when the period is over, so they keep access until then. That one detail prevents a lot of support emails. Our deeper guide to implementing subscription billing covers plan changes, proration and the rest of the lifecycle.
Content gating that does not leak
Hiding a "watch" button is not protection. If the video file or PDF lives at a public URL, anyone with the link has it forever, member or not.
Real gating has three layers:
- Pages. Check membership on the server before rendering any gated page. In Next.js 16, the old
middlewarefile is now calledproxy, and the Next.js authentication guide recommends using proxy only for optimistic checks based on the session cookie. The secure check belongs next to the data. - Data. Every API route and server action that returns gated content checks membership again. Never trust the browser.
- Files. Keep downloads and media in private storage and issue short-lived signed URLs after checking the member is active. Amazon S3 and S3-compatible stores such as Cloudflare R2 support presigned URLs out of the box.
The OWASP authorization cheat sheet is a good reference for the general principle: deny by default and check permissions on every request, server side.
Failed payments, dunning and churn
Failed payments are normal, not rare. Cards expire, get replaced after fraud or hit limits. Without dunning, which means automated retries plus "your card failed" emails, those members churn without ever deciding to leave.
What to put in place:
- Automatic retries. Stripe's Smart Retries choose retry times for you. Turn them on.
- A clear email and in-app banner with a one-click link to update the card.
- A grace period while retries happen, so a member is not locked out over a temporary decline.
- Renewal reminders before yearly renewals, which reduce surprise charges and disputes.
- A graceful ended state. When access ends, show what they are missing and a simple way back, rather than a login error.
Involuntary churn from failed cards is some of the easiest revenue to recover, and most sites leave it on the table. On the voluntary side, a good first week matters as much as billing mechanics. Our post on reducing churn with better onboarding is written for SaaS, but most of it applies directly to memberships.
Easy cancellation is a feature
Hiding the cancel button creates chargebacks, complaints and, in several jurisdictions, legal exposure. In the US, the FTC enforces the Restore Online Shoppers' Confidence Act, which requires clear disclosure of recurring charges, express consent and a simple way to stop them. Several states and other countries have their own automatic-renewal rules on top. This is engineering guidance, not legal advice, so check the rules where your members live.
The simplest compliant setup is a hosted customer portal where members update their card, download invoices and cancel in a couple of clicks. You can still ask why they are leaving or offer a pause, as long as you do not block the exit.
The stack we reach for
Nothing exotic, on purpose. Proven tools are easy to hire for and easy to keep running.
- Next.js for marketing pages, the members area and the API, in one codebase. Server Components render gated content on the server, so it never reaches a browser that should not see it.
- An auth provider or library for login, password reset and sessions. We compare the options in authentication patterns for Next.js.
- Stripe for billing, with webhooks as the source of truth. Our Stripe integration work is mostly about getting this layer right.
- Postgres for your own data: members, their access state and what they can reach.
- Private object storage (S3, R2 or similar) with signed URLs for gated files.
- A transactional email provider for lifecycle emails.
If your content team needs to publish without calling a developer, we add a headless CMS so editors manage articles and lessons while the gating logic stays in code.
The heart of it is a small, well-modelled membership table:
create table memberships (
id uuid primary key default gen_random_uuid(),
user_id uuid not null references users(id),
stripe_customer_id text not null,
stripe_subscription_id text unique,
plan text not null, -- 'monthly' | 'yearly'
status text not null, -- mirrors the Stripe subscription status
current_period_end timestamptz not null, -- access valid until here
cancel_at_period_end boolean not null default false,
created_at timestamptz not null default now(),
updated_at timestamptz not null default now()
);
create index on memberships (user_id);Access becomes one question your server answers on every request: does this user have a membership whose status grants access under your table above, and whose current_period_end (plus any grace period) is still in the future? Webhooks keep those columns accurate. The unique constraint on stripe_subscription_id already creates an index, so it does not need a second one.
What drives the cost
We do not quote a number for a site we have not scoped. These are the decisions that move cost most:
| Decision | Simpler | More complex |
|---|---|---|
| Plans | One tier, monthly and yearly | Several tiers with different content and upgrades |
| Trials and coupons | None at launch | Trials, coupon codes, introductory pricing |
| Content | Articles and downloads | Video, drip schedules, courses with progress |
| Community | None, or an external tool | Built-in forums, comments, moderation |
| Members | Individuals | Group or company memberships with seats |
| Publishing | Content in code or a simple CMS | Custom editorial workflows |
The jump in cost is rarely the UI. It is the extra billing states and access rules each feature introduces. Running costs start modest: hosting, auth, email, storage and payment fees.
Common mistakes to avoid
- Treating payment as a one-time check. If access is decided at checkout only, churned members keep their logins.
- Gating in the front end only. Gate on the server, and use signed URLs for files.
- Ignoring failed payments. No dunning means silent churn.
- Hiding the cancel button. It creates chargebacks and legal exposure. Make leaving as easy as joining.
- Building five tiers on day one. Every plan multiplies billing edge cases. Start with one.
- No admin tools. If fixing a member's access needs a developer, support will not scale.
Where to start
- Define exactly what a member gets, and what they lose when they stop paying.
- Set up one plan with monthly and yearly prices, a hosted checkout and a customer portal.
- Build the membership table and webhook handling, including reconciliation.
- Gate pages, data and files on the server.
- Turn on retries and lifecycle emails before launch, not after.
A membership site lives or dies on one quiet promise: paying members get in, and when they stop paying, they are out, handled correctly every time. That is squarely the kind of product we build. If you are planning one, talk to us and we will help you scope it right the first time.
Membership is also the backbone of many charities and associations; we cover the donor, volunteer and accessibility side of that in web development for nonprofits.
FAQ · 05 questions
Frequently asked questions
What is the best platform for a membership site?
For a simple paid newsletter or community, a hosted membership tool or a WordPress membership plugin gets you live quickly. Build custom when membership is tied to your own product or data, when you need access rules or pricing the tools cannot express, or when platform fees and limits start costing more than owning the software.
How do I protect members-only content?
Check membership status on the server before rendering any gated page or returning any gated data, and keep files in private storage. Generate a short-lived signed URL for each download or video request after confirming the member is active, so a shared link stops working soon after.
What happens when a member's payment fails?
The subscription usually moves to a past-due state while the payment provider retries the card on a schedule. Your site should keep access during a short grace period, email the member with a link to update their card, and remove access only when the subscription is finally cancelled or marked unpaid.
Should a membership site offer monthly and yearly plans?
Yes, usually. Offering both from launch adds little complexity because it is still one tier, and yearly plans improve cash flow and reduce how often cards can fail. Hold off on multiple tiers, which add far more access rules and billing edge cases.
Do I need a developer to run a membership site day to day?
You should not. Members need to manage billing and cancel on their own through a customer portal, and your team needs an admin area to look up members, grant access and issue refunds. If publishing content needs a developer, add a content management system so editors can work independently.