DecaneDocs
Get startedQuick start
Get started

Quick start

Construct one DecaneClient per project and reuse it. On every authenticated route, pull the bearer token from the Authorization header and verify it:

tsauth.ts
import { DecaneClient } from "decane-node";

// Static key (recommended for backends) — copy the ES256 verification key
// from your Decane dashboard. appId is checked against the token's project_id.
const decane = new DecaneClient({
  appId: process.env.DECANE_APP_ID,
  verificationKey: process.env.DECANE_VERIFICATION_KEY, // ES256 SPKI PEM
});

// In your auth middleware:
const token = req.headers.authorization?.replace("Bearer ", "") ?? "";
const claims = await decane.verifyAccessToken(token); // throws DecaneAuthError if invalid
req.userId = claims.userId; // stable Decane user id — key your records off this

To verify against Decane’s remote JWKS instead, just omit verificationKey:

ts
const decane = new DecaneClient({ appId: process.env.DECANE_APP_ID });

That’s the entire setup. The JWKS is fetched lazily on first verification and cached across calls; key rotation is handled automatically without a redeploy.