Hype StackHypeStack

How to Build a SaaS: Six Parts, a Build Order, a Free Starter

GuideThe answer first, the product second.

All stacks

By Maciej Pyrc, who maintains Hype Stack.Published .

A SaaS is six pieces of plumbing and one feature. The plumbing is the same in every product, which is the reason to write as little of it as you can.

Most guides on how to build a saas describe phases: idea, validation, MVP, team. Many are written by agencies, and they end where the sales call begins. They rarely say what the thing is made of.

This page lists the parts a SaaS needs before its first feature, says which to install and which to write, and gives the order to build them in. It assumes you write code, or direct a coding agent that does.

Should you build yet, or prototype first?

How to start a SaaS depends on what you do not know yet. If the open question is whether anyone wants the product, code is a slow way to find out. A waitlist page, a spreadsheet run by hand for five customers, or a prototype from an AI app builder answers it in days and can be thrown away.

Building on a codebase wins when one of these is true:

  • Somebody has asked to pay, or already depends on the prototype.
  • Your customers are teams, so one company's records must stay invisible to another's.
  • You will charge a subscription and gate features by plan.
  • You expect to keep changing the product for months, by hand or with an agent.

The six parts a SaaS app needs before its first feature

Each of these exists in nearly every B2B SaaS, and none of them is why a customer signs up.

PartWhat it has to doWrite it yourself?
Sign-inSessions, password reset, OAuth, expired linksNo. Use a library or a provider
Organizations and rolesA tenant boundary on every table and query, invitations, a role check on every routeInstall the mechanism. Decide who the customer is
Billing with webhooksCheckout, plan changes, and a handler that survives retried and reordered eventsInstall the sync. Write the pricing rules
Transactional emailReset, invitation and receipt emails that reach an inboxRent delivery. Keep the templates in the repository
An admin appLook up a user or an organization without a SQL clientNo. The first screens are the same in most products
A deployApps, database, cache and storage on real URLs, migrations run on each releaseScript it once, early

What you must write is the rest: your domain's tables, the one workflow, and the rules about who may do what and which plan includes what. No starter contains those.

How long the six take from nothing is worked out in SaaS Boilerplate vs Building From Scratch, and the kits that ship them are ranked in Best SaaS Boilerplate 2027.

What to build first: tenancy, then one workflow

The common advice is to build the feature first and add accounts later, because accounts take weeks to write. How to Build a Web App gives that order for a generic app. When sign-in and organizations install in one command the order flips, because tenancy touches every table you add after it.

How to build a SaaS product, in order

  1. Deploy the empty app

    Get sign-in working on a real URL before any feature exists. Missing environment variables and wrong OAuth callback URLs show up while there is nothing else to debug.

  2. Decide who the customer is

    A person or an organization. For teams, every feature table carries an organizationId, every query filters on it, and the id comes from the session rather than the request.

    Hard to change later
  3. Build one workflow

    The thing a customer would pay for, from empty state to result, for a single role.

  4. Add billing when someone agrees to pay

    The subscription belongs to whatever step two chose. Wire the webhook before the pricing page: it is what tells the app a payment happened.

Steps one and two are the cheapest to do first and the most expensive to redo. Admin screens, a second role and receipt emails wait until a customer needs them.

A SaaS MVP is six small parts and one workflow

The usual advice on how to build an MVP is to cut features. For a SaaS, cut features and keep the plumbing: without password reset or a tenant boundary it is a demo.

The MVP is done when

  • A stranger can sign up, reset a password and sign back in
  • Two organizations cannot see each other's rowsSign in as the second organization and request a record from the first by id. Expect the same 404 as a record that does not exist.
  • One workflow runs from empty state to result
  • One paid plan can be bought and cancelled, and the app learns about both from the webhook
  • You can find a customer's account without a SQL client
  • One command ships a new version, migrations included

Safe to cut: a second paid plan, custom roles, notifications, a mobile app, and settings pages beyond profile and members.

How to build a SaaS with AI without breaking the plumbing

A coding agent writes features quickly, because a feature is mostly new files. Plumbing is a rule that has to hold in every file, and that is where agents slip.

What changes when an agent writes the code

It copies the nearest pattern

If the repository has one route that reads the organization id from the session, the next forty will too. If it has none, the agent decides again each session, and sometimes it reads the id from the request body.

Plumbing fails without an error

A list endpoint with no tenant filter still returns data. A webhook handler that applies each event as a change works until two events arrive out of order. Neither failure shows up in a demo.

So the six parts should exist before the first prompt, installed rather than generated, and the agent's time goes to the workflow.

The review list for generated routes is in Web App Security Best Practices, and the agent setup itself, from rules files to the MCP server, is in How to Build an App with AI.

What to start from

We build one such starting point. Hype Stack is a TypeScript codebase (React, Hono, Prisma, Postgres) that a CLI scaffolds and you own as source. The Hono Prisma starter walkthrough covers running it locally. For a SaaS, start from the Better Studio template:

bash
npx @hype-stack/cli template better-studio

What lands in the repository:

  • Sign-in, organizations, roles and an admin app from the SaaS starter, a free pack that installs without a license: email and Google sign-in, password reset, email invitations, admin and member roles enforced by a hasAccess middleware, and Users and Organizations screens in a separate admin app. Better Auth SaaS Template lists the tables.
  • Stripe billing, a paid pack, with one Stripe customer per organization. The handler in libs/stripe/webhook.ts reads only the customer id from each event, then re-reads the subscription from Stripe, so a duplicate or late event lands on the same state. React Stripe Boilerplate walks through it.
  • A dashboard layout and a landing page. The glass layout is also a paid pack.
  • A deploy command. npx @hype-stack/cli deploy web creates the three apps, Postgres, Valkey and a bucket on Fly.io or Railway, and runs migrations as a release step, so a failed migration fails the release.

To pay nothing, run npx @hype-stack/cli compose --packs starter-saas-betterauth,layout-basic instead. Both packs are free, and billing can wait until step four.

With an agent, add npx @hype-stack/cli@latest mcp install, so that "add billing" becomes an add_packs call that copies the pack in instead of code written from memory.

What you add that is not ours

  • Resend for email delivery. The client is wired, but the account, DNS records and bill are yours, and invitations and password resets do not send until RESEND_API_KEY is set.
  • Stripe and a host. Stripe takes its fees, and Fly.io or Railway bills you for hosting. We host nothing.
  • WorkOS, when a customer asks for SSO. starter-saas-workos is the same starter on WorkOS: free to install, billed by WorkOS.

What you write yourself

  • Your domain tables, each with an organizationId, and the routes and screens of the one workflow.
  • Permissions past admin and member: a subject and its grants in packages/enums/src/permissions/presets.ts, then a hasAccess call on the route.
  • Plan gating. The billing pack knows three plan keys, free, pro and premier. Which feature each one opens is a check you write.

What is not in the box

There is no product in it. After sign-in the dashboard is an empty shell, and that is the state you start from.

The billing pack maps each paid plan to one Stripe price. Per-seat and metered pricing are not in it, so if you charge by seat you write that against Stripe's API. The Better Auth starter has no two-factor, passkeys or SAML, and it ships with requireEmailVerification set to false, which you should review before opening signup. Neither starter adds an audit log, and product analytics is not included. You run the deploy, the backups and the upgrades, because this is a codebase and not a hosted service.

Below are the template running, the packs it installs with their tiers, and the command.

The agent side of this build is in How to Vibe Code with Claude.

What is Hype Stack?

Every product starts with the same month of work nobody pays you for: sign-up and login, teams and permissions, taking payments, notifications, an admin panel to run the business. Hype Stack is that month, already built and tested. Start from the free open-source app, add the pieces you need with one command, and keep going on the part that is actually your idea.

Everything lands as real code in your own repository, so there is nothing to rent and nothing anyone can switch off. For the engineers: React 19, Hono, Postgres, and a desktop build, typed end to end.

See it running.

Curated starters built on this stack: a layout, feature packs, a theme, and bonus pages. The previews are recordings of the real apps.
See all 8 templates

Packs in this stack.

Real source code across frontend, backend, and admin. The ones this stack installs come first; the rest compose in later.
SaaS Starter (Better Auth)StarterAuthentication, organizations, roles, sessions, and a full admin app, powered by Better Auth on your own Postgres.Glass LayoutLayoutA glassmorphism dashboard layout: a frosted, blurred sidebar floating over soft color flairs, an org switcher in the header, and an opaque content card that lifts above the glow.Billing (Stripe)FeatureStripe integration, subscriptions, billing flows, and an admin revenue widget.NotificationsFeatureReal-time notifications with WebSocket push, channels, in-app delivery, and admin broadcasts.
See all 20 packs

Two ways to install.

Same features underneath. Either command resolves what the packs need, copies the source into your repo, and merges the Prisma schema.

Take a template

A landing page, a design system, a themed layout, and the features already wired in. Rebrand it, put your product in the middle, ship.

$npx @hype-stack/cli template
Browse templates

Compose your own design

Your design and your choices, without rebuilding auth, billing, or notifications. Tick the packs you want and the CLI wires them into the open-source starter.

$npx @hype-stack/cli compose
Browse packs

Questions, answered.

One language on both sides so types cross the network, Postgres for the data, and tools you can already debug. The stack decides less than people expect. Whether sign-in, organizations and billing exist before your first feature decides more, so pick a stack that has a starter for them.

More stacks.

Your SaaS is one sentence away.

Add a Pro plan at $19 a month with a 14-day free trial.. Let customers invite their team and choose who can do what.. Send a welcome email the moment someone signs up.. Show me which customers are close to their limit this month.. Let people sign in with Google.

Free to start. Works in the AI tool you already use.