A minimal Next.js application demonstrating enterprise SSO via Scalekit using Auth.js (next-auth v5).
git clone https://github.com/scalekit-developers/scalekit-authjs-example.git
cd scalekit-authjs-example
pnpm installcp .env.local.example .env.localFill in .env.local with your Scalekit credentials (see step 3).
In your Scalekit dashboard:
-
Get credentials — Go to API Keys and copy your:
- Environment URL →
AUTH_SCALEKIT_ISSUER(e.g.https://yourenv.scalekit.dev) - Client ID →
AUTH_SCALEKIT_ID(starts withskc_) - Client Secret →
AUTH_SCALEKIT_SECRET
- Environment URL →
-
Register redirect URI — Add the following to your allowed redirect URIs:
http://localhost:3000/auth/callback/scalekit -
Get a Connection ID (optional) — To route sign-in to a specific SSO connection: Go to Organizations → [your org] → Connections and copy the connection ID (
conn_...) →AUTH_SCALEKIT_CONNECTION_ID
pnpm devVisit http://localhost:3000 and click Sign in.
auth.ts— NextAuth config with the Scalekit OIDC providerproviders/scalekit.ts— Local copy of the Scalekit provider (see note below)- Auth routes are served at
/auth/*(basePath is/auth, not/api/auth)
Note: Local provider copy
This example includes
providers/scalekit.tsas a local copy of the Scalekit provider, mirroring the implementation in nextauthjs/next-auth#13392. Once that PR is merged and released, the provider will be available natively innext-auth. At that point:
- Delete
providers/scalekit.ts- In
auth.ts, replace:with:import Scalekit from "./providers/scalekit"import Scalekit from "next-auth/providers/scalekit"
ISC