Installation
Add the SaaS module to a DMS project, connect Stripe, and run the playground with its data set.
@antelopejs/dms-saas runs inside a project that loads @antelopejs/dms in multi-tenant mode, a database module, an e-mail module and a file storage.
Requirements
- A DMS backend in a release that implements the
@antelopejs/interface-dmsrange in the README compatibility table. - The
@antelopejs/dms-frontendrenderer in the range thatengines["@antelopejs/dms-frontend"]offrontend-vue/package.jsondeclares. Theajs dmsCLI refuses to build the module with a renderer outside that range.
Upgrade the DMS backend, @antelopejs/interface-dms and @antelopejs/dms-frontend together, to the ranges above, before you upgrade the module. See DMS installation for the toolchain and Troubleshooting for dependency and frontend integration errors.
Add it to a project
Add the module
ajs project modules add @antelopejs/dms-saas
Set the API keys
Give the module your Stripe keys from the environment, not as committed values:
import { defineConfig } from "@antelopejs/interface-core/config";
export default defineConfig({
name: "my-saas",
envOverrides: {
STRIPE_SECRET_KEY: "modules.dms-saas.config.stripe.secretKey",
STRIPE_PUBLISHABLE_KEY: "modules.dms-saas.config.stripe.publishableKey",
STRIPE_WEBHOOK_SECRET: "modules.dms-saas.config.stripe.webhookSecret",
},
modules: {
"dms-saas": {
source: { type: "package", package: "@antelopejs/dms-saas", version: "^0.16.0" },
config: {
stripe: {
secretKey: "sk_test_placeholder",
publishableKey: "pk_test_placeholder",
webhookSecret: "whsec_...",
},
},
},
// dms, api, mongodb, auth-jwt, nodemailer, file-storage-local, ...
},
});
With placeholder keys, the module still runs. It skips plan syncs, and the blocks that need Stripe say so. The workspace Billing page reads nothing from Stripe either, even for a subscription seeded with a Stripe ID. It renders from the stored subscription and invoices, without the card, and logs no warning.
With placeholder keys, registration takes no card, whatever registration.paymentMethod says, and the registration screens drop their card step as soon as they have loaded the plan they open.
Point Stripe's webhook at the module
Create a webhook endpoint in the Stripe Dashboard that targets https://<api>/api/saas/webhooks/stripe, with the API version 2026-08-26.dahlia. Put its signing secret in STRIPE_WEBHOOK_SECRET. The endpoint answers 404 to every request until Stripe has a usable secret key and the signing secret is not a placeholder. See Stripe.
Publish a free plan
Registration opens every workspace on the first free plan of the catalogue. Create one in Modules › SaaS › Plans (/modules/saas/catalog/plans), or seed it from your module. Until a free plan exists, registration answers 409 saas.errors.plan.no_free_plan.
The auth/no-workspace completion and OAuth sign-ups log the visitor in through the POST /auth/establish route of the frontend server. That route only calls the endpoints that the backend modules declare or that DMS_AUTH_ESTABLISH_ENDPOINTS adds. The module declares /api/saas/register/finalize in its frontend registration, so a frontend server that serves the module needs no environment variable for it.
The pages render on the server, including the plans of the public pricing page. The frontend server reads what a page shows and sends it to the browser with the page. The Stripe reads that a page renders give up after stripe.readTimeoutMs (4 seconds by default). The past-due and trial-ending strips of the layout read the billing state stored in the database, not Stripe. Dialogs and drawers read their data when they open.
Try it in the playground
The playground is not a workspace package and has its own lockfile. Install the workspace, build the module, and install the playground from the repository root:
pnpm install --frozen-lockfile
pnpm build
pnpm --dir packages/dms-saas/playground install --frozen-lockfile --ignore-workspace
Then start the backend and the dashboard, each in its own terminal:
cd packages/dms-saas
pnpm dev # backend on http://localhost:5010
pnpm frontend:dev # dashboard on http://localhost:3001
The playground connects to MongoDB at mongodb://localhost:27017. To use another server, set MONGO_URL in the environment or in playground/.env. The playground reads the Stripe keys and the GitHub and Google OAuth credentials from playground/.env, which is never committed. See playground/.env.example. The sign-in button of a provider appears once both its client ID and its secret are set. Register http://localhost:3001/auth/oauth/<provider>/callback as its callback URL.
Playground data set
On its first start against an empty database, the playground writes a data set that covers every screen. Sign in as [email protected] with the password Playground-Admin-1!. This account is a platform admin and also owns the acme workspace. The platform admins [email protected] and [email protected], and every seeded workspace owner and member, use the same password.
The data set holds the following records:
- The feature and plan catalogue: Free, Starter, Pro, Team, Business per seat, Enterprise (yearly and hidden), and Growth 2024 (retired).
- Thirteen workspaces in every billing state, with their members and invitations. The states are active, trialing, free, complimentary with and without an end date, past due, pending payment, suspended, and cancelled.
- Invoices in every status, credit notes, plan migrations, segments, internal notes, billing rules and legal documents.
Dates are relative to the first start. The Stripe IDs are fake, so nothing calls Stripe for them, and the actions that do call Stripe (plan changes, cancellation, refunds) fail on these workspaces. The crons of the module still advance them. The past-due workspace is suspended once it has been past due for longer than the suspension delay, and the cancelled one is deleted after the data retention period. To try the billing flows, give the playground Stripe test keys and run pnpm stripe:webhooks. See Demos, tests and seeded data.
The seed lives in playground/src/seed. It runs once, when the DMS provisions its default tenant (TENANT_BEING_PROVISIONED). To start over, drop the database. Segment counts appear after the first recompute, which runs every 15 minutes. The running plan migration turns to "reconciliation required" on the next restart, as an interrupted migration does.