@clerk/nextjs
7.10.2 · 17 Nov 2026MIT4.2M / weekRepositoryHomepagenpmAtom feed
6.39.9 is the newest release of 6.x.
In short
3 new1 fixed4 internal
Security
3 advisories affect 6.21.0; 6.39.3 fixes them
- CriticalOfficial Clerk JavaScript SDKs: Middleware-based route protection bypassGHSA-vqx2-fgx2-5wq9 · 16 Apr 2026Fixed in 6.39.2
- HighClerk has an authorization bypass when combining organization, billing, or reverification checksGHSA-w24r-5266-9c3c · 30 Apr 2026Fixed in 6.39.3
- High@clerk/backend Performs Insufficient Verification of Data AuthenticityGHSA-9mp4-77wg-rwx9 · 9 Jul 2025Fixed in 6.23.3
Release note
Minor Changes
Introduces machine authentication, supporting four token types:
api_key,oauth_token,machine_token, andsession_token. For backwards compatibility,session_tokenremains the default when no token type is specified. This enables machine-to-machine authentication and use cases such as API keys and OAuth integrations. Existing applications continue to work without modification.You can specify which token types are allowed for a given route or handler using the
acceptsTokenproperty in theauth()helper, or thetokenproperty in theauth.protect()helper. Each can be set to a specific type, an array of types, or'any'to accept all supported tokens.Example usage in Nextjs middleware:
import { clerkMiddleware, createRouteMatcher } from '@clerk/nextjs/server'; const isOAuthAccessible = createRouteMatcher(['/oauth(.*)']); const isApiKeyAccessible = createRouteMatcher(['/api(.*)']); const isMachineTokenAccessible = createRouteMatcher(['/m2m(.*)']); const isUserAccessible = createRouteMatcher(['/user(.*)']); const isAccessibleToAnyValidToken = createRouteMatcher(['/any(.*)']); export default clerkMiddleware(async (auth, req) => { if (isOAuthAccessible(req)) await auth.protect({ token: 'oauth_token' }); if (isApiKeyAccessible(req)) await auth.protect({ token: 'api_key' }); if (isMachineTokenAccessible(req)) await auth.protect({ token: 'machine_token' }); if (isUserAccessible(req)) await auth.protect({ token: 'session_token' }); if (isAccessibleToAnyValidToken(req)) await auth.protect({ token: 'any' }); }); export const config = { matcher: [ '/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)', '/(api|trpc)(.*)', ], };Leaf node route protection:
import { auth } from '@clerk/nextjs/server'; // In this example, we allow users and oauth tokens with the "profile" scope // to access the data. Other types of tokens are rejected. function POST(req, res) { const authObject = await auth({ acceptsToken: ['session_token', 'oauth_token'] }); if (authObject.tokenType === 'oauth_token' && !authObject.scopes?.includes('profile')) { throw new Error('Unauthorized: OAuth token missing the "profile" scope'); } // get data from db using userId const data = db.select().from(user).where(eq(user.id, authObject.userId)); return { data }; }The
svixdependency is no longer needed when using theverifyWebhook()function.verifyWebhook()was refactored to not rely onsvixanymore while keeping the same functionality and behavior.If you previously installed
svixto useverifyWebhook()you can uninstall it now:npm uninstall svix
Patch Changes
Updated URL for 'auth() was called but Clerk can't detect usage of clerkMiddleware()'
Introduce
getAuthObjectFromJwtas internal utility function that centralizes the logic for generating auth objects from session JWTs.
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.