Skip to content

Deprecate middleware-based auth gating: shared notice + multi-SDK protect-pages#3404

Closed
jacekradko wants to merge 3 commits into
mainfrom
jacek/deprecate-createroutematcher-foundation
Closed

Deprecate middleware-based auth gating: shared notice + multi-SDK protect-pages#3404
jacekradko wants to merge 3 commits into
mainfrom
jacek/deprecate-createroutematcher-foundation

Conversation

@jacekradko

Copy link
Copy Markdown
Contributor

First in a stacked series moving Clerk away from middleware-based auth gating (createRouteMatcher and auth checks inside clerkMiddleware) toward protecting close to the resource. Background: Deprecate middleware-based auth checks.

Foundation only: a shared _partials/middleware-auth-deprecation.mdx that holds the deprecation wording in one editable place (it's included everywhere downstream), and protect-pages reworked into a multi-SDK guide. The new Next.js base covers page, route handler, Server Action, and layout protection, and flags that a layout check isn't a security boundary because layouts don't re-render on soft navigation. The existing Nuxt content moved verbatim to protect-pages.nuxt.mdx; it gets rewritten in the Nuxt PR.

One thing worth a look: the partial uses full-strength "deprecated" wording even though the SDK hasn't shipped @deprecated yet. It's isolated to that one file so softening it later is a one-line change.

… make protect-pages multi-SDK

Adds docs/_partials/middleware-auth-deprecation.mdx as the single source of truth for the deprecation notice, and reworks protect-pages into a multi-SDK guide (Next.js base covering page/route handler/Server Action/layout protection with the layout re-render caveat; existing Nuxt content moved to protect-pages.nuxt.mdx).
@jacekradko
jacekradko requested a review from a team as a code owner May 29, 2026 21:26
@vercel

vercel Bot commented May 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
clerk-docs Ready Ready Preview Jun 5, 2026 3:24am

Request Review

Strip the exploit-level language (normalize/percent-encoding/extra path
segment/authorization bypass) from the shared partial and the protect-pages
'Why not protect in middleware?' section, pending the unpublished advisory.
Keep the honest non-security motivation: middleware route matching is a
second model of your routes that drifts out of sync. Posture wording
('deprecated') unchanged here; that is part of the partial redraft under review.
Partial: soften posture to 'no longer recommended' (SDK has not shipped
@deprecated), lead with the re-file/locality story, keep clerkMiddleware()
explicitly blessed for non-auth work. Document the Gate 1/Gate 2 toggles.

protect-pages: add a 'Migrating from middleware checks' section, before/after
for a single matcher, a requireUser() helper for subtrees, the add-first
remove-last ordering for the protect-all inversion (with a fail-open warning),
and onward links. auth.protect() return shape verified against clerk/javascript.
@jacekradko

Copy link
Copy Markdown
Contributor Author

Heads up: this PR is part of the createRouteMatcher deprecation stack, which is being re-stacked on top of #3426.

#3426 carries a reframed, positive-recommendation version of the shared middleware-auth-deprecation partial plus the reworked Next.js protect-pages guidance, and is intended to merge to main first. Once it lands, this stack will be rebased onto it and pared down to the deltas it doesn't already cover.

Keeping do not merge until the rebase, no action needed here yet.

@jacekradko

Copy link
Copy Markdown
Contributor Author

Superseded by #3426. The shared middleware-auth-deprecation partial and multi-SDK protect-pages approach here was replaced in #3426 by inline, per-page deprecation notices on the renamed protect-content guides. Closing in favor of #3426 (head 468fc4df4), the canonical createRouteMatcher deprecation PR, which ships coordinated with clerk/javascript#8994.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants