Clerk logo

Clerk Docs

Ctrl + K
Go to clerk.dev

Next.js server-side changes

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

API routes

Helpers for API routes have been updated to mirror the new useAuth hook on the client-side.

  • withSession is deprecated and replaced with withAuth
  • requireSession is deprecated with replaced with requireAuth
  • 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

Edge middleware

Edge middleware has also been updated to mirror the new useAuth hook on the client-side. The import path has also been changed to avoid confusion.

Was this helpful?

Clerk © 2022