FLOWDocs

Self-hosting

Configure a separate Flow ID issuer and its app integrations.

Self-hosting runs a separate identity issuer. Its users, signing credentials, database, and relying-party configuration do not automatically become the hosted Flow identity service. The npm SDK is a client library; running an issuer also requires access to the Auth service source and its deployment configuration.

Required foundations

Use the service's supported Bun runtime and PostgreSQL database. Configure a unique BETTER_AUTH_SECRET, the externally reachable BETTER_AUTH_URL, DATABASE_URL, and the WebAuthn PASSKEY_RP_ID and PASSKEY_RP_NAME. Use HTTPS for a production relying party. Never deploy development secrets or a test fee-payer mnemonic.

From an authorized source checkout, use the committed database migrations:

bun install --frozen-lockfile
bun run db:migrate
bun run dev

bun run dev is the supported local launcher. It prints the actual local endpoints; use those values instead of assuming fixed ports. Development credentials bound to localhost do not become production credentials. Generate new migrations when changing the schema, and apply the committed chain before starting the matching release. Schema push is not a production migration strategy.

Register apps and callbacks

Configure the issuer's allowed origins in src/origins.ts. An app's audience is its exact origin, including its port in development. The default callback is that origin's /flow/session. For a custom path, register its exact full URL through FLOW_ID_CALLBACK_URLS and configure the matching path in both browser and server SDKs. Callback URLs must not contain credentials, queries, or fragments.

Set the consumer's APP_ORIGIN behind a reverse proxy, its server-side FLOW_ID_HOST, and the browser SDK's host consistently. JWT verification pins the public issuer even when server-side API transport uses a separate address. Do not derive trusted origins from arbitrary incoming headers.

Keep the WebAuthn related-origins manifest consistent with the origins you actually support. Signing prompts, top-level sign-in, and first-party application cookies have different browser constraints; a historical CHIPS auth iframe setup does not replace the current session handler.

Optional capabilities

Configure production email delivery for email codes. Outside production, the service can log development email codes instead of sending them; do not treat that as a production mail setup. Email sends and browser authorization issuance have persisted quotas.

External sign-in providers need their own registered callbacks, provider credentials, and encrypted credential storage. Configure only the providers you intend to offer. Avatar storage, public-content services, fee sponsorship, and downstream room services each need their own configuration; they are not supplied by pointing an app at the SDK.

Scheduled work runs through the service's worker entry point (bun run worker), separately from the API. Deploy the workers required for the capabilities you enable, including event reminders and maintenance. Keep shared service credentials server-side and separate by purpose.

Operate the issuer

Back up the database and required encrypted-storage keys, retain migration history, and test recovery with downstream data-erasure requirements. Let the service publish and rotate its JWT keys; consuming apps should use its JWKS endpoint. Protect logs from cookies, bearer tokens, codes, and private key material.

See Getting started for consumer setup and JWT verification for issuer and audience checks.

On this page