WorkOS is an enterprise authentication platform that provides AuthKit (hosted login UI), Single Sign-On (SSO), SCIM directory sync, and user management. This example shows how to integrate WorkOS with InsForge in a Next.js application — WorkOS handles authentication and enterprise identity, while InsForge manages data authorization through Row Level Security (RLS) policies.
This is a Next.js todo list app where users sign in via WorkOS AuthKit and manage their own todos stored in InsForge.
git clone https://github.com/InsForge/insforge-integration.git
cd insforge-integration/auth/workos
npm install
cp .env.example .env.localCreate a new project in the InsForge dashboard and link it:
npx @insforge/cli link --project-id <your-project-id>Get your InsForge URL and Anon Key from Project Settings in the InsForge dashboard.
Get your JWT Secret:
npx @insforge/cli secrets get JWT_SECRET- Log in to your WorkOS Dashboard
- Go to API Keys and note down the API Key and Client ID
- Navigate to Redirects and add
http://localhost:3000/callback - Go to Authentication > Sessions > Configure JWT Template
- Set the template to:
{
"role": "authenticated",
"aud": "insforge-api",
"user_email": {{ user.email }}
}
subis a reserved claim automatically included by WorkOS — do not add it manually.
- Save the template
Fill in .env.local:
# WorkOS
WORKOS_API_KEY='sk_example_...'
WORKOS_CLIENT_ID='client_...'
WORKOS_COOKIE_PASSWORD='use [openssl rand -hex 32] to generate a 32 bytes value'
NEXT_PUBLIC_WORKOS_REDIRECT_URI='http://localhost:3000/callback'
# InsForge
NEXT_PUBLIC_INSFORGE_URL='YOUR_INSFORGE_URL'
NEXT_PUBLIC_INSFORGE_ANON_KEY='YOUR_INSFORGE_ANON_KEY'
INSFORGE_JWT_SECRET='YOUR_INSFORGE_JWT_SECRET'npm run devOpen http://localhost:3000 and sign up with a new user through WorkOS AuthKit.
Note: Since authentication is handled entirely by WorkOS, you will not see any users in the InsForge dashboard under Auth > Users. User records are managed in the WorkOS Dashboard.
For a detailed walkthrough of the integration, see the WorkOS Integration Guide.