Open source · MIT · Deno 2
The groundwork of a SaaS, already built.
Template is an open-source starter for multi-user web products. Accounts with a second factor, groups with roles, billing per member, realtime and an offline app are wired together, so your first week goes to your product, not to sign-in.
The demo is the app you get on day one, with nothing added.
Who it is for
Developers starting a product that many people use together, who want sign-in, groups, billing and deployment settled before the first feature. It runs on a server you control. Skip it if you deploy to serverless functions.
What you get
Each part works today.
Sign-in that is done
Sign-up, sign-in and sessions in a signed cookie. E-mail verification by one-time code, password reset and an authenticator-app second factor.
Groups with roles
Every account gets a group at sign-up. Invite members, give them roles from viewer to owner, hand ownership over. Groups are the one boundary every rule checks.
Billing per member
Stripe subscriptions per group: a free plan with limits, a paid plan per member, trials, cancelling and notices when a payment fails.
Realtime
A change reaches every open tab over a WebSocket, and an app that wakes up from the background catches up on what it missed.
An app that works offline
The web app installs like a native one, opens with no network and queues writes. A write that went stale shows as a conflict to settle, never as a silent overwrite.
Web push
People allow notifications once and get them on their phone or desktop, with the keys created for you.
A worker with an outbox
The API writes an event in the same transaction as the change; the worker sends the mail and does the slow work after, so nothing is lost when a step fails.
Deploy to your own server
Docker Compose for development and one-server production: Traefik with certificates, Postgres, Valkey, MinIO, VictoriaMetrics, VictoriaLogs and Grafana.
A public website
This site: rendered on the server, works with JavaScript turned off, with pricing, legal pages and a newsletter with double opt-in.
How it works
Four parts, one repository, one server.
The API
Hono on Deno. It holds every rule: who may do what, in which group. It is the only part that writes to Postgres.
The web app
Preact. It is what your users sign in to. It calls the API and listens on a WebSocket, so it shows other people's changes as they happen.
The worker
It reads the events the API wrote next to each change and does the slow work: mail, notifications, clean-up.
The website
Fresh, rendered on the server, like this page. It explains your product and links into the app.
Quick start
You need Deno 2, Docker and the GitHub CLI.
gh repo create my-product --template spy4x/template --private --clone
cd my-product
cp infra/envs/.env.example infra/envs/.env # then fill in the secrets
deno task vapid-key:create
deno task proxy:start
deno task devThen open the address in DOMAIN, app.localhost by default. The README lists every secret to fill in and how to deploy.
Honest status
Work in progress, built in public. Here is where it stands.
Works today
- Sign-up, sign-in, e-mail verification, password reset and the second factor
- Groups with members, roles, invitations and ownership transfer
- Billing per member with trials, through Stripe
- Notes, the example feature to copy for your own
- Realtime updates, the offline app and web push
- The outbox worker, the mailing list and this website
Not built yet
- Sign-in with Google, GitHub or passkeys
- Downloading an account's data
- Parts of the worker
Built in public
I'm Anton Shubin. I build client MVPs on this template and develop it in the open. If something is missing for your product, or you just want to say what you think, open an issue or write to me.