Skip to content

scalekit-developers/scalekit-authjs-example

Repository files navigation

Scalekit + Auth.js Example (Next.js)

A minimal Next.js application demonstrating enterprise SSO via Scalekit using Auth.js (next-auth v5).

Prerequisites

Getting Started

1. Clone and install

git clone https://github.com/scalekit-developers/scalekit-authjs-example.git
cd scalekit-authjs-example
pnpm install

2. Configure environment

cp .env.local.example .env.local

Fill in .env.local with your Scalekit credentials (see step 3).

3. Configure Scalekit

In your Scalekit dashboard:

  1. 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 with skc_)
    • Client Secret → AUTH_SCALEKIT_SECRET
  2. Register redirect URI — Add the following to your allowed redirect URIs:

    http://localhost:3000/auth/callback/scalekit
    
  3. 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

4. Run the app

pnpm dev

Visit http://localhost:3000 and click Sign in.

How it works

  • auth.ts — NextAuth config with the Scalekit OIDC provider
  • providers/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.ts as 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 in next-auth. At that point:

  1. Delete providers/scalekit.ts
  2. In auth.ts, replace:
    import Scalekit from "./providers/scalekit"
    with:
    import Scalekit from "next-auth/providers/scalekit"

License

ISC

About

Next.js example app demonstrating enterprise SSO with Scalekit and Auth.js (next-auth v5)

Topics

Resources

License

Stars

Watchers

Forks

Contributors