Web App Developer Guides

Drop-in middleware for verifying Twingate Identity Firewall JWTs in your web app.

These guides provide drop-in middleware for verifying Twingate Identity Firewall JWTs in common web frameworks. Each guide follows the same pattern: verify the ES256-signed JWT from the Authorization header, extract the user’s identity, and make it available to your application code. For architecture details and the full JWT reference, see the Identity Firewall for Web Apps overview.

Guides

Express.js

Node.js middleware using the jose library. Attaches the verified identity to req.twingateIdentity.

Express.js developer guide

Django

Python middleware using PyJWT. Attaches the verified identity to request.twingate_identity.

Django developer guide

Next.js

Edge Middleware for the Next.js App Router using jose. A thin middleware gates the routes you choose, and a reusable helper verifies the JWT to read the authenticated identity in route handlers and Server Components.

Next.js developer guide

Next.js + Auth.js

Combines Twingate Identity Firewall with Auth.js (NextAuth v5) sessions. Instead of passing identity via a request header, the middleware verifies the Twingate JWT and mints an Auth.js session cookie. This gives you auth() in Server Components and useSession() in Client Components.

Next.js + Auth.js developer guide

Last updated 3 hours ago