Zero Accessby Railmandocs
Compose

Multi-instance

Shared storage, deploymentMode, and conformance for multi-node elevate and zero-access.

Multi-instance

Lab sketches use deploymentMode: "single-instance" with process-local stores. That is fine for a single-node demo. Do not ship it for multi-worker or multi-region Better Auth.

This page covers how to graduate any compose guide to shared infrastructure.

What changes

ConcernSingle-instance (lab)Multi-instance (production)
deploymentMode"single-instance""multi-instance" on elevate / zeroAccess
Elevate challenges, rate limits, TOTP replayMemory maps / lab storesShared store via Better Auth secondaryStorage or explicit stores + conformance capabilities
Zero-access ephemeral / secondaryProcess-localShared DO / Redis / KV with conformance evidence
Recovery IP rate limitingOften disabled until trusted edgeAfter BA advanced.ipAddress + blocking direct origin, set recoveryIpAddressTrust: "trusted-edge" (required under securityLevel: "strict")

Pattern

export const auth = betterAuth({
  secret: process.env.BETTER_AUTH_SECRET!,
  // secondaryStorage: shared DO / Redis / KV
  session: { cookieCache: { enabled: false } },
  plugins: [
    ...passkeyStack.plugins,
    loginFactors(),
    elevate({
      deploymentMode: "multi-instance",
      passkeyCounterGuard: passkeyStack.controller,
      // Wire shared stores or BA secondaryStorage + conformance capabilities.
      passwordOnlyIfNoStronger: true,
      elevatedTtlSec: 300,
    }),
    zeroAccess({
      deploymentMode: "multi-instance",
      // securityLevel: "strict",
      // recoveryIpAddressTrust: "trusted-edge",
      requireRecoveryExportAck: true,
      assertAccess: /* createZeroAccessAssertAccess(…) */,
    }),
  ],
});

Full production-shaped sketch: Quick start. Plugin option surface: Plugin contract · API.

Conformance

Method presence on a store is not enough. Run the package conformance harnesses and pass the returned capabilities into the plugins (secondaryStorageSecurity, elevate store capabilities, and so on). Fail closed if the harness rejects the binding.

Security graduation

Passkey stack posture and zeroAccess securityLevel: "strict" are separate from deployment mode. You can be multi-instance at standard while integrating; pin strict (and trusted recovery IP) when the edge story is real.

See gradual security on Passkey login and the hard rules on Checklist.

Next

Do not ship

Process-local Map stores and single-instance mode behind a load balancer silently split elevate challenges and rate limits across nodes.

On this page