- 19 Feb, 2026 9 commits
-
-
nextjs-bot authored
-
JJ Kasper authored
## Summary - expose the active app source page on `window.next.__n_src_page` - derive the source page from the client router tree instead of sending it via `InitialRSCPayload` - ensure the value updates on client transitions (including dynamic routes and route groups) - extend app-dir e2e coverage for initial load and transition behavior ## Testing - `pnpm test-dev test/e2e/app-dir/app/index.test.ts -t "__n_src_page"` - `pnpm --filter=next types`
-
Zack Tanner authored
The latest version is causing deploy test failures. x-ref: https://github.com/styled-components/styled-components/issues/5667 x-ref: https://github.com/vercel/next.js/actions/runs/22162110706/job/64084432174#step:34:375
-
Jimmy Lai authored
## Summary Fix dead-code elimination in `packages/next/cache.js` to prevent server-only internals from being pulled into browser bundles. Restructures the conditional exports so bundlers can properly tree-shake server paths. ## Test plan - [ ] `pnpm --filter=next build` succeeds - [ ] No runtime behavior changes --------- Co-authored-by:Tim Neutkens <tim@timneutkens.nl>
-
Tobias Koppers authored
## What? Adds a `maybe-build-native.mjs` script to `packages/next-swc/` that conditionally rebuilds native SWC bindings during `pnpm build`. The script is integrated into the turborepo pipeline as the `build` task for `@next/swc`. ## Why? Developers often forget to run `pnpm swc-build-native` after pulling Rust changes, leading to confusing runtime errors. Conversely, rebuilding native binaries when nothing changed wastes significant time. This automates the decision so `pnpm build` always does the right thing. ## How? The `maybe-build-native.mjs` script runs as `@next/swc`'s `build` task and: 1. **Skips in CI** — exits immediately when the `CI` env var is set, since CI uses prebuilt `@next/swc-*` npm packages 2. **Finds the last version bump** — uses `git log -G` to locate the commit that last changed `"version":` in `packages/next/package.json` 3. **Checks for Rust changes** — compares `*.rs` files against the working tree (committed + staged + unstaged) since that version bump commit 4. **Rebuilds if needed** — runs `build-native` and copies/formats the generated TypeScript definitions 5. **Clears stale binaries** — if no Rust changes are detected, removes any leftover `.node` files from `native/` so the prebuilt npm packages are used instead Turborepo's `turbo.json` is configured with Rust-specific inputs (`crates/`, `Cargo.*`, `rust-toolchain`) and `CI` in `env` so CI and local builds get separate cache keys. ### Files changed - `packages/next-swc/maybe-build-native.mjs` — new script with the conditional build logic - `packages/next-swc/package.json` — added `"build": "node maybe-build-native.mjs"` - `packages/next-swc/turbo.json` — added `build` task with Rust inputs, `CI` env, and `native/*.node` outputs
-
Jimmy Lai authored
## Summary Use `Buffer.indexOf` when available in `uint8array-helpers.ts` for faster byte sequence scanning. Falls back to the existing manual loop on non-Node environments. ## Test plan - [ ] `pnpm test-unit test/unit/stream-utils/uint8array-helpers.test.ts` passes
-
Niklas Mischkulnig authored
-
Hendrik Liebau authored
Runtime prefetch responses previously encoded `isPartial` and `staleTime` using a sentinel-and-replace pattern: a random number was embedded in the RSC payload during prerendering, then a TransformStream scanned the prelude stream to find and replace it with the actual values. This was fragile because it relied on matching a specific byte sequence in a chunked stream that could be split at arbitrary boundaries. This replaces that mechanism with two simpler approaches: - **isPartial**: A single byte prepended to the response stream (`#` for complete, `~` for partial). - **staleTime**: An `AsyncIterable<number>` in the Flight payload that yields updated stale time values as the prerender store changes. This ensures the latest value is always serialized in the stream, even when sync IO aborts the prerender before the abort callback runs. The stale time tracking logic is extracted into a new `stale-time.ts` module with `StaleTimeIterable`, `trackStaleTime`, and `finishStaleTimeTracking`. On the client, dynamic runtime prefetch responses (detected via the absence of `NEXT_IS_PRERENDER_HEADER`) have the byte stripped before Flight decoding, and the stale time is read by iterating the async iterable. Static responses served from cache are handled unchanged.
-
Benjamin Woodruff authored
Turbopack: Derive `Default` on `PartialProjectOptions`, remove silly `partial_project_options_with_debug_build_paths` helper (#90170) TSIA
-
- 18 Feb, 2026 27 commits
-
-
Benjamin Woodruff authored
Rust finally merged a fix to the "trying to encode a dep node twice" ICE we seem to most frequently run into, triggered by the rustc parallel frontend feature: https://github.com/rust-lang/rust/pull/151509 - @mischnic commented on the issue: https://github.com/rust-lang/rust/issues/150018#issuecomment-3754877064 - @mischnic just updated our toolchain last week, but I'd like to get this fix in. CI Job for build-and-release that covers all platforms: https://github.com/vercel/next.js/actions/runs/22156881743 In the process of this upgrade, I found and reported https://github.com/rust-lang/rust/issues/152735 upstream (fixed `nightly-2026-02-18`).
-
nextjs-bot authored
-
Vercel Release Bot authored
This auto-generated PR updates the development integration test manifest used when testing Rspack.
-
Vercel Release Bot authored
This auto-generated PR updates the production integration test manifest used when testing Rspack.
-
Josh Story authored
Stacked on #89984 When we initially implemented runtime prefetching we decided to make sync IO that happens after runtime but before async IO an error. This is similar to but more aggressive than the error for sync IO before runtime data but is important because if you have sync IO before uncached IO and we are runtime prefetching the page then we aren't going to get anything useful from that prefetch but it might be very expensive. The problem with the current implementation is that if you turn on runtime prefetching for a Page segment then in practice the router will only ever runtime prefetch that page segment but the sync IO validator will error for sync IO before uncached IO anywhere in the route. This makes adding runtime prefetching to leaf Segments much harder b/c you have to address sync IO in the entire Segment stack. This change updates the sync IO heuristic to only error in segments that would be runtime prefetched and below. This way when you add runtime prefetching to a segment you only have to true up the sync IO for the part of the tree that has the changed behavior. This PR only partially implements the intended semantics for runtime prefetching validation of sync IO. One thing that will need to be done in a follow up is handling sync IO in generateMetadata. In this case while the functions are defined in layouts and pages they are semantically always "owned" by the page itself. This means that while the layout might not be runtime prefetchable and thus allow sync IO after runtime data access the generateMetadata in that same layout might not allow sync IO after runtime if there is a runtime prefetch config at the page level or some layout higher. This will be done in a follow up
-
Zack Tanner authored
`NextURL` intentionally canonicalizes loopback hosts (127.x.x.x, [::1], localhost) to localhost so that internal URL handling is consistent across equivalent local origins. However, we were applying a regex replacement to the entire URL before parsing, which unintentionally rewrote loopback strings inside query parameter values, eg `?redirect_uri=http%3A%2F%2F127.0.0.1...`. This is unexpected for anyone that is explicitly passing through different loopback values. This fixes it by first parsing the URL with `new URL()`, and then only apply the replacement logic to `parsed.hostname` when it is a loopback host. This leaves search unchanged. Fixes NEXT-4864
-
Luke Sandberg authored
# Refactor JSON module handling in Turbopack ## What? Moves the JSON module handling from a separate crate (`turbopack-json`) into the `turbopack-ecmascript` crate as a source transform, similar to how text and binary files are handled. ## Why? This simplifies the codebase by: 1. Removing a separate crate dependency 2. Using a consistent pattern for handling non-JavaScript assets * notably by sending them through the normal asset pipeline we unlock other behaviors in turbopack like scope-hoisting 3. Improving error handling for invalid JSON files ## How? - Removed the `turbopack-json` crate - Added a new `json_source_transform.rs` module to `turbopack-ecmascript` - Implemented two modes for JSON handling: - Spec-compliant ESM mode (for `import ... with { type: 'json' }`) - Webpack-compatible CommonJS mode (for regular imports) - Added "no side effects" directive to JSON, text, and binary modules to preserve tree shaking - Updated error handling to provide better feedback for invalid JSON - Opt'd out traced modules from json/bytes/text processing, this is more correct and should be a bit faster. On the other hand this exposed a subtle issue with traced dependencies -
Niklas Mischkulnig authored
This should reduce some duplicate CI jobs. This split existed to support separate dev/prod manifests for skipping tests. That's not needed anymore, so we can just switch to the Webpack setup. This manual partitioning of `integration` tests into dev vs prod was brittle anyway We still need this setup for rspack though
-
Tobias Koppers authored
## What? This PR enables tree-shaking for dynamic imports when the imported module's exports are destructured or accessed via member expressions. Previously, dynamic imports were treated as importing all exports, preventing unused exports from being removed. ## Why? Dynamic imports with destructuring patterns like `const { cat } = await import('./lib')` or member access like `(await import('./lib')).cat` now properly communicate which specific exports are actually used. This allows bundlers (particularly Turbopack) to tree-shake unused exports from dynamically imported modules, reducing bundle size. ## How? ### Core Changes: 1. **AST Analysis Enhancement** (`turbopack-ecmascript/src/analyzer/graph.rs`): - Added new `Effect::DynamicImport` variant that captures destructuring patterns and member access - Implemented `extract_dynamic_import_export_names()` to statically analyze destructuring patterns and extract used export names - Supports: const/let/var destructuring, renamed imports, nested destructuring, default exports, member access, and empty destructuring 2. **Export Usage Tracking** (`turbopack-core/src/resolve/mod.rs`): - Added `ExportUsage::NamedSet` variant to track multiple named exports being used - Updated `ModuleExportUsageInfo` to handle merging of multiple named exports 3. **Dynamic Import Reference** (`turbopack-ecmascript/src/references/esm/dynamic.rs`): - Extended `EsmAsyncAssetReference` with `export_names` field - Implemented `binding_usage()` to communicate which exports are used to the module graph 4. **Effect Processing** (`turbopack-ecmascript/src/references/mod.rs`): - Refactored dynamic import handling into dedicated `handle_dynamic_import()` function - Passes export usage information through the reference system ### Test Coverage: - **E2E Tests** (`test/e2e/app-dir/dynamic-import-tree-shaking/`): Comprehensive tests for Next.js App Router covering various destructuring patterns - **Snapshot Tests** (`turbopack-tests/tests/snapshot/basic-tree-shake/`): Turbopack-specific tests validating tree-shaking behavior ### Supported Patterns: -✅ Named destructuring: `const { cat } = await import('./lib')` -✅ Variable declarations: `var`, `let`, `const` -✅ Renamed imports: `const { cat: myCat } = await import('./lib')` -✅ Nested destructuring: `const { dogRef: { get } } = await import('./lib')` -✅ Default exports: `const { default: val } = await import('./lib')` -✅ Empty destructuring: `const {} = await import('./lib')` (side effects only) -✅ Member access: `(await import('./lib')).cat` ### Limitations: - Rest patterns (`const { cat, ...rest }`) conservatively import all exports - Computed property keys are not statically analyzed - Member access tree-shaking is Turbopack-only (webpack limitation) https://claude.ai/code/session_01QWi3udq2LX4GFqJEDaqFFU -
Sebastian "Sebbie" Silbermann authored
Flagged behind `experimental.appNewScrollHandler` `focus()` on Fragment refs works different than `findDOMNode(this).focus()`. `findDOMNode` will return an actual host element so it's effectively `HTMLElement.focus()`. If the element isn't focuseable, `focus()` will do nothing. By spec, there's also no way to determine if an element is focusable. It's up to user agents (e.g. sometimes scrollable containers are considered focusable). `FragmentInstance.focus` will focus the first focusable descendant. That could be a focusable element deep within the fragment e.g. `<Fragment><section><p>A lot of text</p><a href="">Next page</a></Fragment>`. Focusing such a deep element may sometimes be counter productive. Now we just blur the active element. This is how a hard navigation already works today and ensures we don't skip past content of the new segment. This means you potentially stay a long way before the actual Segment (e.g. in a preceding nav) with the focus cursor which could be annoying. We could be clever and temporarily insert a focusable element at the start of the Segment, focus it, and then immediately remove. That would leave the focus cursor right before the Segment. However, this requires knowledge about the parent content (can we just insert an element of our choosing?) and relies on knowing what's focusable (a button would be a good bet). That's a bit too clever for a fix without concrete motivation so I'm waiting somebody to complain about the new behavior.
-
Sebastian "Sebbie" Silbermann authored
We try to focus the new Segment after navigation. This behavior currently has now tests. I plan to change that behavior behind `experimental.appNewScrollHandler` so I'm adding some tests for the current behavior. The test is also meant as a fixture for manual testing with a screen reader.
-
nextjs-bot authored
-
Zack Tanner authored
`maxPostponedStateSize` should be verified in all cases where the postponed body is buffered. This fixes a branch in self-hosted setups where that check was missing.
-
Jude Gao authored
Updates the `AGENTS.md` content generated by `create-next-app` to use clearer wording that better signals to models that their training data may be outdated. The prompt wording was determined by running evals continuously until we found a prompt that is objectively unbiased and shows no signs of regression on any tests across all models. **Before:** > Next.js: ALWAYS read docs before coding > Before any Next.js work, find and read the relevant doc in `node_modules/next/dist/docs/`. Your training data is outdated — the docs are the source of truth. **After:** > This is NOT the Next.js you know > This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` before writing any code. Heed deprecation notices.
-
Niklas Mischkulnig authored
So that we don't hash asset contents multiple times. `hash_xxh3_hash64(file.content())` isn't a turbotask, but `file.hash()` is cached
-
Niklas Mischkulnig authored
We have two lines of defense: 1. crates/next-custom-transforms/src/transforms/react_server_components.rs validates ESM imports of server-only and client-only and throws an issue if something is wrong. Notably, `require('server-only')` isn't caught by this 2. additionally, we had an `BeforeResolvePlugin` for server-only, client-only and styled-jsx. We should probably get rid of the first one completely for consistency (it's brittle) https://github.com/vercel/next.js/blob/79040a318d29641eb3d96a5a47c92a5f8506e826/crates/next-custom-transforms/src/transforms/react_server_components.rs#L663-L674 This PR is about improving the second one: The error message isn't ideal yet, but better than before (note: no import trace): ``` ./bench/basic-app/app Invalid import 'server-only' cannot be imported from a Client Component module. It should only be used from a Server Component. The error was caused by importing 'bench/basic-app/app' ``` now <img width="708" height="386" alt="Bildschirmfoto 2026-01-07 um 17 21 59" src="https://github.com/user-attachments/assets/4d49eff3-4959-4b70-aa47-6f3c10c75588" /> -
Tim Neutkens authored
## For Maintainers ### What? Optimize the `parseMaxPostponedStateSize` function by using a pre-calculated byte value for the default size limit instead of parsing it each time. ### Why? This optimization improves performance (though it's a very small impact) since `parseMaxPostponedStateSize` is in the hot path for rendering. By using a pre-calculated constant value for the default case, we avoid unnecessary parsing operations. ### How? - Added a constant `DEFAULT_MAX_POSTPONED_STATE_SIZE_BYTES` with the pre-calculated value of 100MB in bytes (104,857,600) - Modified `parseMaxPostponedStateSize` to return the pre-calculated constant when no size is provided - Only call `parseSizeLimit` when a custom size is specified
-
Niklas Mischkulnig authored
To test the change in https://github.com/vercel/next.js/pull/89915
-
Tim Neutkens authored
### What? Handle `null` `history.state` in the client-side router's `popstate` handler. ### Why? When `pushState` or `replaceState` is called outside of Next.js with a `null` state (or the initial history entry has no state), navigating back/forward to that entry fires a `popstate` event with `event.state === null`. Previously, the `onPopState` handler returned early without doing anything, leaving the router tree completely out of sync with the browser URL — `usePathname()`, `useSearchParams()`, etc. would return stale values. ### How? When `event.state` is `null`, call `window.location.reload()` to perform a hard navigation, the same behavior as when a non-Next.js history entry is encountered (`!event.state.__NA`). This ensures the router always returns to a consistent state. Added an e2e test that: 1. Navigates to a second page via client-side Link 2. Pushes history entries with truly `null` state (via `History.prototype.pushState` to bypass the Next.js patch) 3. Goes back and verifies the page correctly reloads Fixes #90080
-
Zack Tanner authored
This fixes an issue where deploying an app that explicitly named a catch-all segments as `[...segments]` or `[[...segments]]` would lead to repeated ISR cache misses on that route, even if it was generated at build time. This is because the normalizer that is responsible for extracting the segment path wasn't escaping the `.segments` directory value, so the `.` was treated as a wildcard. That meant when the server attempted to look up the underlying segment data, it wouldn't find it and would have responded with a 204, which signals to the upstream CDN that it is not a cacheable response. Fixes #87090
-
Vercel Release Bot authored
This auto-generated PR updates the production integration test manifest used when testing Rspack.
-
Vercel Release Bot authored
This auto-generated PR updates the development integration test manifest used when testing Rspack.
-
Luke Sandberg authored
Defer cell creation so it doesn't happen inside of async loops There are a number of async functions in the resolve package that either directly construct ResolveResult or defer to a turbo task function, this leads to non-determinism when callers invoke these in async loops. The fix is just to defer cell creation out of these async helper functions. This was discovered by enabling the `verify_determinism` feature in #90013
-
nextjs-bot authored
-
Josh Story authored
Stacked on #89978 When the AbortSignal passed to the StagedRenderingController is aborted there is some logic to potentially abort any unresolved stage promises. Semantically anything we have a render with a stage controller that is aborted we must ensure no stage promises are left in a perpetually pending state.
-
Luke Sandberg authored
Reverts vercel/next.js#90096 * always `track_mutation()` before the mutation * only `track_mutation()` if we are actually going to mutate The previous attempt was reverted because we would call `track_modification` too often which lead to a test failure in the filesystem-cache-test because the DB grew too much.
-
Josh Story authored
Stacked on #90065 The older methods were so close in function to runInSequentialTasks we've now unified the interface and use it consistently everywhere.
-
- 17 Feb, 2026 4 commits
-
-
Luke Sandberg authored
The recent change to move task description formatting onto `TaskGuard` introduced a subtle issue when formatting these rare error messages.
-
Sebastian "Sebbie" Silbermann authored
-
nextjs-bot authored
-
-