Overview
WorkOS is an enterprise authentication platform that provides AuthKit (hosted login UI), Single Sign-On (SSO), SCIM directory sync, and user management. This guide 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.- Live Demo — A sample app using WorkOS authentication with InsForge
- Source Code — GitHub repository for the sample app
Prerequisites
- An InsForge project (self-hosted or cloud)
- A WorkOS account
Step 1: Create a WorkOS Application
- 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 - Enable your desired authentication methods (email/password, social login, SSO, etc.)
Step 2: Set Up Your InsForge Project
Create a new project or link an existing one:Step 3: Set Up Your Application
Install the required dependencies:.env.local:
Step 4: Set Up InsForge Integration
Ask your agent to complete the following steps:1. Set up WorkOS AuthKit and InsForge integration
app/callback/route.ts), AuthKitProvider wrapper (app/layout.tsx), middleware (middleware.ts), and login route (app/login/route.ts).
2. Create the InsForge client utility
lib/insforge.ts) that gets the WorkOS user via withAuth(), signs a JWT with the InsForge secret, and passes it as edgeFunctionToken.
3. Create the database schema
requesting_user_id() helper function (since WorkOS user IDs are strings, not UUIDs) and a todos table with Row Level Security policies.
4. Build the todo list page
Step 5: Run Your Application
http://localhost:3000 and sign up with a new user through WorkOS.
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 — check Users there to confirm the sign-up was successful.
