Skip to Content
Clerk logo

Clerk Docs

Ctrl + K
Go to clerkstage.dev

Express server-side changes

Before starting this guide, please complete the Client-side changes.

Middleware

Express middleware been updated to mirror the new useAuth() hook on the client-side.

  • ClerkExpressWithSession is deprecated and replaced with ClerkExpressWithAuth
  • ClerkExpressRequireSession is deprecated and replaced with ClerkExpressRequireAuth
  • Instead of decorating the Request object with a Session object, it is now decorated with an Auth object that mirrors useAuth() on the client-side.
    • const { userId, sessionId, getToken } = req.auth;

Example usage

import { ClerkExpressRequireAuth } from '@clerk/clerk-sdk-node'; app.use(ClerkExpressRequireAuth()); app.get('/', (req, res) => { const { userId, sessionId, getToken } = req.auth; // Your handler... })

What did you think of this content?

Clerk © 2023