@clerk/nextjs: Pages Router builds bundle next/headers into the client via the App Router provider
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- nextjs, react, typescript
- Área
- build-system, frontend
Línea de trabajo
Start with the import chain: dist/esm/client-boundary/ClerkProvider.js loads both the App Router and Pages Router providers, and app-router/server-actions.js is a "use server" file that imports cookies from next/headers. Build a minimal Pages Router app with ClerkProvider in pages/_app, run next build, and search .next/static/chunks for RequestCookiesAdapter. Done means the client chunks no longer contain next/headers, and the App Router path still works. The maintainers have not chosen between an opt-in entry point and lazy loading, so confirm the approach first.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
This issue was written by Claude Code, but verified by me.
Reproduction
No separate repo. It shows up in any Pages Router app that renders ClerkProvider from @clerk/nextjs: build it and search the client chunks for Next's cookie code (e.g. RequestCookiesAdapter).
Publishable key
N/A. The problem is in the build output, not the instance.
Description
In a Pages Router app, ClerkProvider adds Next's server request code to every route's client JS: cookies, headers, draft mode and the edge cookie parser. In our app that's 18.5 KB gzipped per route.
The import chain, in @clerk/nextjs 7.4.3:
dist/esm/client-boundary/ClerkProvider.jsimports bothapp-router/client/ClerkProviderandpages/ClerkProvider, and picks one at runtime withnext/compat/router. Both are bundled.app-router/client/ClerkProvider.jsimportsinvalidateCacheActionfromapp-router/server-actions.js.server-actions.jsis a"use server"file that importscookiesfromnext/headers.
An App Router build turns that file into a server-action reference. A Pages Router build has no server-action boundary, so the file and the whole next/headers graph land in the client bundle.
Steps to reproduce:
- Create a Pages Router app with
ClerkProviderinpages/_app.tsx. - Run
next build. - Search
.next/static/chunksforRequestCookiesAdapterorResponseCookies.
Expected behavior:
A Pages Router app's client bundle doesn't include next/headers.
Actual behavior:
Every route's client bundle includes next/headers and the request code behind it.
Workaround:
We alias next/headers to a stub in the browser only:
// next.config.ts
turbopack: {
resolveAlias: {
'next/headers': { browser: './src/utils/next-headers-browser.ts' },
},
},
The stub exports cookies, headers and draftMode, each of which throws if called. Nothing calls them, since the App Router provider never renders under the Pages Router.
Possible fixes:
Bundling both providers makes sense for apps that mix routers. For Pages-only apps, either of these would avoid it:
- An opt-in Pages Router entry point that doesn't import the App Router provider.
- Load the App Router provider, or just
invalidateCacheAction, lazily, so a Pages Router build doesn't pull innext/headers.
Environment
System:
OS: macOS 26.6.2
CPU: (12) arm64 Apple M2 Pro
Binaries:
Node: 24.15.0
pnpm: 12.16.1
npmPackages:
@clerk/nextjs: ^7.4.3 => 7.4.3
@clerk/shared: ^4.15.0 => 4.15.0
next: 16.4.2 => 16.4.2
react: 19.2.6 => 19.2.6
react-dom: 19.2.6 => 19.2.6
Bundler: Turbopack (next build)
- Lenguaje dominante
- TypeScript
- Estrellas
- 1.8k
- Forks
- 492
- Merge medio
- 1 d 8 h
- PR fusionados (30 d)
- 374
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de clerk/javascript
-
<SignIn />: the reset password code step renders an empty, focusable back button with no accessible namePosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
clerk/javascript#10708 ·
Los mantenedores suelen responder en 1 día
-
Built-in reverification dialog lacks an accessible name (aria-dialog-name)Posiblemente ocupada @ItsShivam05 la tomó hace 5 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
clerk/javascript#10548 ·
Los mantenedores suelen responder en 1 día
-
MFA enrollment QR SVG lacks an accessible name (svg-img-alt)Posiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
clerk/javascript#10547 ·
Los mantenedores suelen responder en 1 día
-
<SignIn />: first "Use email" click switches back to phone when `initialValues.phoneNumber` is setPosiblemente ocupada @twicestruck la tomó hace 22 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
clerk/javascript#10487 ·
Los mantenedores suelen responder en 1 día
-
useLoadedIsomorphicClerk misses "ready" when a ClerkProvider remounts after clerk-js has loaded — <ClerkLoading> never resolvesQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
clerk/javascript#10462 ·
Los mantenedores suelen responder en 1 día
Todos los issues de clerk/javascript
Issues similares
-
`@angular/[email protected]` depends on vulnerable Vite 7.3.7 - GHSA-p4f5-76q4-ffq7 (Critical RCE)Abiertoarea: @angular/build
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
angular/angular-cli#34764 ·
Los mantenedores suelen responder en 1 día
-
status/need-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
google-gemini/gemini-cli#30384 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
P2
Dificultad 1/5 Menos de una hora Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
bug ready-for-human
Dificultad 2/5 1-3 horas Aptitud para principiantes 60/100
LucasSantana-Dev/Lucky#3150 ·
Los mantenedores suelen responder en 1 día
-
enhancement good first issue priority: low size: XS
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día