Skip to main content

Overview

Auth0 is an authentication and authorization platform that supports social logins, enterprise federation, and passwordless authentication. This guide shows how to integrate Auth0 with InsForge in a Next.js application. Auth0 handles authentication, while InsForge manages data authorization through Row Level Security (RLS) policies. On each server request, the app signs a fresh InsForge JWT from the Auth0 session using your InsForge secret, so InsForge accepts it natively.
  • Live Demo — A sample app using Auth0 authentication with InsForge
  • Source Code — GitHub repository for the sample app

Prerequisites

  • An InsForge project (self-hosted or cloud)
  • An Auth0 account and tenant
  • A Next.js application (or any framework — adjust the client code accordingly)

Step 1: Create an Auth0 Application

  1. Log in to your Auth0 Dashboard
  2. Go to Applications > Applications > Create Application
  3. Choose Regular Web Application and give it a name (if prompted to select a technology, choose Next.js or skip — it only affects which quickstart guide Auth0 shows you)
  4. In the Settings tab, configure:
    • Allowed Callback URLs: http://localhost:3000/auth/callback
    • Allowed Logout URLs: http://localhost:3000
  5. Note down the Domain, Client ID, and Client Secret

Step 2: Set Up Your InsForge Project

Create a new project or link an existing one:
Then get your project credentials:
Note down the URL and Anon Key from the InsForge dashboard. You’ll use the JWT Secret from the CLI output in a later step to sign tokens for InsForge.

Step 3: Set Up Your Application

Install the required dependencies:
Add environment variables to .env.local:

Step 4: Set Up InsForge Integration

Ask your agent to complete the following steps:

1. Set up Auth0 authentication

This creates the Auth0 client (lib/auth0.ts), middleware (middleware.ts), and Auth0Provider wrapper (app/layout.tsx).

2. Create the InsForge client utility

This creates a server-side utility (lib/insforge.ts) that gets the Auth0 user via auth0.getSession(), signs a JWT with the InsForge secret, and passes it as edgeFunctionToken.

3. Create the database schema

This creates the requesting_user_id() helper function (since Auth0 user IDs are strings, not UUIDs) and a todos table with Row Level Security policies.

4. Build the todo list page

This creates a page that uses the InsForge client to manage todos. RLS ensures users only see their own data.

Step 5: Run Your Application

Open http://localhost:3000 and sign up with a new user through Auth0.
Since authentication is handled entirely by Auth0, you will not see any users in the InsForge dashboard under Auth > Users. User records are managed in the Auth0 Dashboard — check User Management > Users there to confirm the sign-up was successful.
InsForge Auth Users — empty because Auth0 manages users