1. 11 Mar, 2026 11 commits
    • nextjs-bot's avatar
      v16.2.0-canary.92 · 29812f26
      nextjs-bot authored
      29812f26
    • Will Binns-Smith's avatar
      Tracing: tag spans as failed if their runner fn fails (#91206) · f803fa7c
      Will Binns-Smith authored
      This adds a dedicated attribute, `failed`, to a span representing if the
      procedure failed. It's then set if the runner function threw.
      
      Test Plan: Added an e2e test
      f803fa7c
    • Tim Neutkens's avatar
      fix: correct appPaths sort order for parallel routes with route groups (#91160) · 21b9f6ba
      Tim Neutkens authored
      ### What?
      
      Fixes webpack dev 404s when parallel routes have children nested inside
      a route group (e.g. `@slot` + `(b1)/page`) and when a parallel route has
      `page.tsx` directly inside it (e.g. `@slot/page.tsx`).
      
      ### Why?
      
      Two separate issues caused 404s for parallel routes with route groups:
      
      1. **Sort order**: The three `appPaths` sort sites used bare `.sort()`
      (lexicographic ordering). `renderPageComponent` relies on
      `appPaths[appPaths.length - 1]` being the children/root page. Without
      route groups this works because `@` (0x40) sorts after lowercase letters
      — `/@slot/page` comes before `/page`. But when the children page is
      inside a route group, `(` (0x28) sorts before `@` (0x40), flipping the
      order: `/(b1)/page < /@slot/page`. Now the last item is the slot page
      instead of the children page, so the manifest lookup fails and a 404 is
      returned.
      
      2. **Double `__PAGE__` segment**: When a parallel route like `@slot` has
      `page.tsx` directly inside it, `resolveParallelSegments` returns
      `[PAGE_SEGMENT]` (an array) to signal that the loader should recurse
      into the slot directory to pick up layout/default files. However, the
      segment key normalization was mapping `PAGE_SEGMENT` to
      `PAGE_SEGMENT_KEY` (`__PAGE__`), while the recursion would also produce
      a `__PAGE__` for children — creating a double `__PAGE__` nesting (`slot:
      ['__PAGE__', { children: ['__PAGE__', ...] }, ...]`).
      
      ### How?
      
      **Sort order fix**: Adds a `compareAppPaths` comparator in
      `packages/next/src/shared/lib/router/utils/app-paths.ts` that sorts
      paths containing `/@` segments before paths without them, ensuring the
      children page is always last. Replaces the three bare `.sort()` calls
      with `.sort(compareAppPaths)` in:
      
      - `packages/next/src/build/entries.ts`
      - `packages/next/src/server/lib/router-utils/setup-dev-bundler.ts`
      -
      `packages/next/src/server/route-matcher-providers/dev/dev-app-page-route-matcher-provider.ts`
      
      **Loader tree fix**: Maps `PAGE_SEGMENT` to `'(slot)'` in the segment
      key normalization (same as `PARALLEL_VIRTUAL_SEGMENT`), instead of
      `PAGE_SEGMENT_KEY`. By the time this code is reached,
      `parallelSegmentKey === PAGE_SEGMENT` only occurs for the array case
      (the string case is handled by the early return), so this is safe. The
      actual `__PAGE__` is correctly created by the recursion.
      
      **Before:** `slot: ['__PAGE__', { children: ['__PAGE__', ...] }, ...]`
      **After:** `slot: ['(slot)', { children: ['__PAGE__', ...] }, ...]`
      
      Also adds an e2e test that verifies the fix across all modes (Turbopack
      dev, Turbopack start, webpack dev).
      21b9f6ba
    • Niklas Mischkulnig's avatar
      Lint against `.context(format!(...))` (#91122) · 19ff1bab
      Niklas Mischkulnig authored
      There are unfortunately a few false-positives, because this isn't aware of type information of course.
      19ff1bab
    • Luke Sandberg's avatar
      [Turbopack] Don't attempt to compress key blocks containing small keys (#90881) · c65b4347
      Luke Sandberg authored
      In turbo-persistence, if a key block has small keys don't attempt to compress the key block
      
      Currently all of our tables have small keys and none of them actually meet our compression threshold, thus all the time we spend attempting to compress them is just wasted CPU time.
      c65b4347
    • Tobias Koppers's avatar
      Add experimental.lightningCssFeatures config option (#90901) · 187f35f2
      Tobias Koppers authored
      ### What?
      
      Adds a new `experimental.lightningCssFeatures` config option that lets
      users control which CSS features lightningcss should always transpile
      (`include`) or never transpile (`exclude`), regardless of browserslist
      targets.
      
      ```js
      // next.config.js
      module.exports = {
        experimental: {
          useLightningcss: true,
          lightningCssFeatures: {
            include: ['light-dark', 'oklab-colors'],
            exclude: ['nesting'],
          },
        },
      }
      ```
      
      ### Why?
      
      Currently, lightningcss feature transpilation is determined solely by
      browserslist targets. There's no way to force transpilation of a
      specific feature (e.g., `light-dark()`) when targeting modern browsers
      that already support it, or to skip transpilation of a feature that the
      user wants to preserve as-is.
      
      This is useful for:
      - Forcing polyfill-style transpilation for features with incomplete
      browser support
      - Testing transpiled output for specific features
      - Opting out of specific transforms that may interfere with CSS tooling
      downstream
      
      ### How?
      
      **TypeScript config & validation:**
      - `config-shared.ts`: `LIGHTNINGCSS_FEATURE_NAMES` const array (single
      source of truth) with `LightningCssFeature` type derived from it, and
      `LightningCssFeatures` interface
      - `config-schema.ts`: Zod validation using
      `z.enum(LIGHTNINGCSS_FEATURE_NAMES)` for both include/exclude arrays
      
      **Feature name → bitmask mapping (Rust, shared via NAPI):**
      - `crates/next-core/src/next_config.rs`:
      `lightningcss_feature_names_to_mask()` maps feature name strings to
      `lightningcss::targets::Features` bitflag constants and returns a
      `Result<u32>` bitmask. Unknown feature names produce an error via
      `bail!`.
      - Exposed to JS via NAPI as `lightningcssFeatureNamesToMaskNapi`,
      callable through `bindings.css.lightning.featureNamesToMask(names)`
      - Single source of truth for feature name resolution — both webpack and
      Turbopack paths use this Rust function
      
      **Webpack path:**
      - `global.ts` / `modules.ts` pass config through to loader options
      - `loader.ts` calls `featureNamesToMask()` via the native bindings to
      compute include/exclude masks, then passes them to the SWC `transform()`
      call
      - The `lightningCssFeatures` without `useLightningcss` warning only
      shows when using webpack (Turbopack always uses lightningcss)
      
      **Turbopack path (Rust):**
      - `next_config.rs`: `LightningCssFeatures` struct for deserialization,
      accessor methods converting names → u32 bitmask via
      `lightningcss_feature_names_to_mask()`
      - Config flows through `CssOptionsContext` → `ModuleType::Css` →
      `CssModuleAsset` (using `LightningCssFeatureFlags { include, exclude }`
      struct) → `process.rs` where bitmasks are merged into
      `lightningcss::targets::Targets { include, exclude }`
      - Uses `u32` bitmask representation throughout to avoid adding
      lightningcss dependency to non-CSS crates
      
      **Defaults preserved:** `Nesting | MediaRangeSyntax` for Turbopack,
      `Nesting` for Webpack. User `include` is OR-ed on top, user `exclude`
      masks bits off.
      
      **Feature names:** 21 individual features (bit 0–20) + 3 composite
      groups (`selectors`, `media-queries`, `colors`), all in dash-case.
      
      ### Test
      
      - **Include test**
      (`test/e2e/app-dir/experimental-lightningcss-features/`) — targets
      Chrome 123 (which natively supports `light-dark()`) with `include:
      ['light-dark']`, then asserts the CSS output contains lightningcss
      transpilation markers (`--lightningcss-light`, `--lightningcss-dark`)
      instead of raw `light-dark()`.
      - **Exclude test**
      (`test/e2e/app-dir/experimental-lightningcss-features-exclude/`) —
      targets Chrome 100 (which does NOT support `light-dark()` natively) with
      `exclude: ['light-dark']`, then asserts the CSS output preserves raw
      `light-dark()` calls and does not contain transpilation markers.
      187f35f2
    • Luke Sandberg's avatar
      [turbopack] Render code frames on the turbopack side (#90534) · ff36c17c
      Luke Sandberg authored
      Not that error rendering performance is critical, but it is silly to pass frame information from turbopack to js just to have js pass the same information back to native code to draw a frame.
      ff36c17c
    • JJ Kasper's avatar
    • Benjamin Woodruff's avatar
      docs(turbopack): Merge old turbo-tasks concept mdbook page with crate's top-level rustdoc (#91120) · a18ae7d7
      Benjamin Woodruff authored
      Merges the content from https://turbopack-rust-docs.vercel.sh/turbo-engine/concepts.html with the crate-level documentation we already had, and adds some some graphics from https://nextjs.org/blog/turbopack-incremental-computation (currently linking to the vercel blob bucket).
      
      ### Rendered
      
      ![Screenshot 2026-03-09 at 14-35-56 turbo_tasks - Rust.png](https://app.graphite.com/user-attachments/assets/2233e4d1-c249-4be2-af02-d15bd4b9a0cf.png)
      a18ae7d7
    • Luke Sandberg's avatar
      [turbopack] Move empty snapshot filtering into take_snapshot (#90166) · a5f36eb2
      Luke Sandberg authored
      When snapshotting we create a number of iterators to encode every `shard` of the `modified` dashmap.
      
      Some of these shards end up being empty and rarely they might all be empty.   To avoid the overhead of opening a write transaction we detect this prior to persisting.  Unfortunately this is done in a single threaded pass and can be expensive since there are often thousands of shards.
      
      To improve this we move the filtering into shard production so it can happen concurrently.
      
      This is a small improvment, from vercel-site builds timing the `Finished writing to filesystem cache` event we get
      
      Before: 6.6s 7.8s 7.1s
      After: 6.6s 6.5s 6.4s
      
      So a small progression
      a5f36eb2
    • Luke Sandberg's avatar
      [turbopack] hashing improvements to turbo-persistence (#90936) · 7640d0bd
      Luke Sandberg authored
      ## Summary
      
      Reduces CPU overhead in turbo-persistence SST reads through three optimizations:
      
      1. **Switch from `twox-hash` to `xxhash-rust`** — `twox_hash::XxHash3_64::with_seed(0)` heap-allocates a 192-byte secret buffer on every call. `xxhash_rust::xxh3::Xxh3Default::new()` is a `const fn` with zero allocation. Applied to both `turbo-persistence` and `turbo-tasks-hash`.
      
      2. **Bulk `write()` in `KeyBase::hash` impls** — The hash implementations were feeding bytes one at a time via `write_u8()`, preventing xxh3 from using its optimized bulk ingestion path. Changed all slice-backed types (`&[u8]`, `[u8; N]`, `Vec<u8>`, `Box<[u8]>`) to use a single `state.write(slice)` call.
      
      3. **Binary search improvements in SST lookups:**
         - **Index block lookup**: Replaced hand-rolled binary search with `as_chunks::<10>()` + stdlib `binary_search_by`, making the code simpler and leveraging the stdlib's optimized search.
         - **Duplicate key scans**: When collecting all entries with the same key (FIND_ALL mode), the backward/forward scans now use the binary search bounds (`l..m` and `m+1..r`) instead of scanning from `0` to `entry_count`. The binary search already proved entries outside these bounds are different, so this avoids unnecessary comparisons.
         - **`entry_matches_key` helper**: Equality checks during duplicate scans now use a dedicated function that avoids recomputing the full hash when no hash is stored in the block (block type 2/4). Previously `compare_hash_key` would call `hash_key()` to compute the full hash even when only an equality check was needed.
      
      ## Benchmark results
      
      Compared against the `fixed_size_blocks` branch using `cargo bench -p turbo-persistence -- 'read/get/key_8'` (8-byte keys, 4-byte values):
      
      | Benchmark | Change |
      |-----------|--------|
      | 10.67Mi/compacted/miss/cached | **-45%** |
      | 10.67Mi/compacted/hit/cached | **-35%** |
      | 10.67Mi/uncompacted/hit/cached | **-35%** |
      | 10.67Mi/uncompacted/hit/uncached | **-22%** |
      | 10.67Mi/uncompacted/miss/uncached | **-22%** |
      | 10.67Mi/uncompacted/miss/cached | **-21%** |
      | 10.67Mi/20commits/hit/cached | **-26%** |
      | 10.67Mi/20commits/miss/* | -13% |
      | 85.33Mi/compacted/hit/uncached | **-56%** |
      | 85.33Mi/compacted/hit/cached | **-22%** |
      | 85.33Mi/compacted/miss/* | **-22%** |
      | 85.33Mi/uncompacted/hit/cached | -10% |
      | 85.33Mi/20commits/hit/uncached | -12% |
      | 85.33Mi/20commits/hit/cached | -6% |
      | 85.33Mi/20commits/miss/* | -1 to -3% |
      
      Largest wins on cached paths with smaller datasets where CPU cost (hashing, search) dominates over I/O.
      7640d0bd
  2. 10 Mar, 2026 16 commits
    • nextjs-bot's avatar
      v16.2.0-canary.91 · c44558be
      nextjs-bot authored
      c44558be
    • Luke Sandberg's avatar
      [turbopack] Encode task storage directly during persistence (skip clone) (#89412) · 9cee46cd
      Luke Sandberg authored
      # Don't clone TaskStorage objects when snapshotting the database
      
      ## What
      
      Instead of cloning `TaskStorage` objects when preparing to snapshot, we directly encode from a reference to the `TaskStorage` in the backend storage map.
      
      ## Why
      
      From a performance profile of `save_snapshot`, I observed that ~22% of the time was spent in `clone_meta_snapshot` or `clone_data_snapshot`, while ~28% of the time was spent in `encode_task_data`. The whole reason we are cloning is so we can drop the lock on the dashmap shard while encoding. In principle this makes sense, however:
      
      * We are only holding *read* locks on the dashmap, so we don't block other encoding threads
      * Holding the read locks for slightly longer will just slow down racing writing threads, but those are rare and already incur a high cost due to the extra cloning in `track_modification`. So slowing them down isn't too risky.
      
      ## Perf
      
      On a vercel-site cold build i don't actually see a real change in persistence time
      
      
      Before: 6.6s 7.8s 7.1s
      After: 6.9s 6.6s 7.2s
      
      So we are saving cpu time and allocations from this change but the overall task is bound on IO, so we should really only expect a win on more CPU constrained systems.
      9cee46cd
    • Luke Sandberg's avatar
      [turbopack] Add support for fixed key blocks (#90844) · f1f83236
      Luke Sandberg authored
      ## What?
      
      Adds fixed-size key block types to turbo-persistence SST files. When all entries in a key block share the same key size and value type, the 4-byte-per-entry offset table is eliminated entirely. Entry positions become a direct arithmetic calculation: `header_size + index * stride`.
      
      Also fixes a bug in `sst_inspect` where value blocks were misidentified as key blocks (value blocks have no type header, so their raw data could coincidentally match a key block type byte).
      
      ## Why?
      
      Many turbo-persistence tables have uniform key and value sizes. For example, TaskCache stores 4-byte task ID keys with 4-byte inline values — every single entry is identical in structure. The existing variable-size key block format stores a 4-byte offset table entry per entry (1B type + 3B position) to support variable-length entries. For uniform blocks, this offset table is pure overhead in both space and read-path indirection (binary search must chase offset table pointers at each step).
      
      ## How?
      
      **New block types 3 and 4** (parallel to existing types 1/2 for hash/no-hash):
      
      ```
      Variable: [1B type][3B count][4B offset × count][entries...]
      Fixed:    [1B type][3B count][1B key_size][1B value_type][entries...]
      ```
      
      The 2 extra header bytes (key_size + value_type) are amortized across all entries since we save 4 bytes per entry from removing the offset table. Break-even at 1 entry.
      
      **Writer changes:**
      - `KeyBlockFormat` enum with state machine (`Unknown → Fixed → Variable`) tracks uniformity as entries are added to the accumulator
      - `FixedKeyBlockBuilder` writes the compact 6-byte header + contiguous entries with no offset table
      - Falls back to variable-size automatically when entries aren't uniform
      - `ValueRef::write_value_to()` shared across both builder types to avoid duplication
      
      **Reader changes:**
      - `lookup_fixed_key_block()` — binary search using stride arithmetic (pure arithmetic, zero conditional branching per step)
      - `get_fixed_key_entry()` — direct index calculation instead of offset table indirection
      - Iterator refactored with `CurrentKeyBlockKind` enum (Variable vs Fixed variants)
      
      **sst_inspect fix:** Reads the index block first to determine which block indices are key blocks, rather than guessing from the first byte of block data.
      
      ### Real-world impact (vercel-site .next cache, ~9.5M entries per family)
      
      | Family | Fixed Blocks | Variable Blocks | Key Block Size | Notes |
      |--------|-------------|----------------|---------------|-------|
      | **TaskCache** | **16,274 (100%)** | 0 | **108.82 MB** (was 145 MB, **-25%**) | All inline 4B values |
      | TaskMeta | 10,078 (72%) | 3,877 (28%) | 118.86 MB (was ~145 MB) | Variable blocks contain rare medium values |
      | TaskData | 39 (0.3%) | 13,943 (99.7%) | 144.45 MB | Medium values spread across most blocks |
      | Infra | 0 | 1 | 25 B | Mixed inline sizes |
      
      This also saves 73M (2%) of the overall cache size
      
      ### Read-path benchmarks (`static_sorted_file_lookup`, 8B keys + 4B values)
      
      | Benchmark | Canary | Fixed Blocks | Change |
      |---|---|---|---|
      | **1Ki hit/cached** | 534 ns | 510 ns | **-4.5%** |
      | **10Ki hit/cached** | 559 ns | 556 ns | ~0% |
      | **100Ki hit/cached** | 566 ns | 503 ns | **-11.1%** |
      | **1Mi hit/cached** | 573 ns | 519 ns | **-9.4%** |
      | 1Ki miss/cached | 571 ns | 571 ns | ~0% |
      | 10Ki miss/cached | 613 ns | 556 ns | **-9.3%** |
      | 100Ki miss/cached | 639 ns | 593 ns | **-7.2%** |
      | 1Mi miss/cached | 791 ns | 702 ns | **-11.3%** |
      | 1Ki hit/uncached | 4.07 µs | 3.81 µs | **-6.4%** |
      | 10Ki hit/uncached | 5.33 µs | 5.03 µs | **-5.6%** |
      | 100Ki hit/uncached | 5.55 µs | 5.24 µs | **-5.6%** |
      | 1Mi hit/uncached | 8.47 µs | 8.31 µs | **-1.9%** |
      | 1Ki miss/uncached | 3.37 µs | 3.19 µs | **-5.3%** |
      | 10Ki miss/uncached | 3.87 µs | 3.41 µs | **-11.9%** |
      | 100Ki miss/uncached | 4.15 µs | 3.70 µs | **-10.8%** |
      | 1Mi miss/uncached | 6.98 µs | 6.66 µs | **-4.6%** |
      
      Consistent **5-11% improvement** on cached lookups (the hot path in production), where the binary search dominates and offset table elimination matters most. Uncached lookups also improve 2-12% due to smaller blocks and faster binary search.
      f1f83236
    • nextjs-bot's avatar
      v16.2.0-canary.90 · 36698c94
      nextjs-bot authored
      36698c94
    • JJ Kasper's avatar
      Revert "Address review feedback: extract modules, clean up imports" (#91159) · a2551c49
      JJ Kasper authored
      This is causing issues in unit tests so reverting to avoid regression
      there.
      
      Reverts vercel/next.js#90813
      a2551c49
    • Joseph's avatar
      docs: Streaming guide (#90779) · 69f53fd9
      Joseph authored
      - [x] update links to demo
      - [x] minor polishing identified by AI
      - [x] update links (dep: docs-unify-caching-story)
      - [x] check the implementation details vs actionable info balance
      - [x] how (and when) to block streaming?
      https://github.com/vercel/next.js/pull/90450
      - [x] INP and the hydrate me later trick link to demo
      
      ---------
      Co-authored-by: 's avatarDelba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
      69f53fd9
    • Joseph's avatar
    • Dmitrii's avatar
      fix(css): rewrite MiniCssExtractPlugin insert function to ES5 to support legacy browsers (#90556) · ae9c9d6c
      Dmitrii authored
      ## What?
      
      Rewrite the `insert` function passed to `MiniCssExtractPlugin` in
      `packages/next/src/build/webpack/config/blocks/css/index.ts` to use only
      ES5-compatible syntax.
      
      ## Why?
      
      The `insert` option of `mini-css-extract-plugin` serialises the function
      via `Function#toString()` and injects the resulting string directly into
      the webpack runtime chunk. This string **bypasses all subsequent
      transpilation** — it is not processed by Babel/SWC, and is not subject
      to the project's `browserslist` or `output.environment` webpack config.
      
      The current function contains:
      
      ```js
      const { href, onload, onerror } = linkTag   // ES2015 destructuring
      onload?.call(linkTag, ...)                  // ES2020 optional chaining
      ```
      
      When the project targets legacy browsers (e.g. `chrome >= 45`) pages
      crash on load with:
      
      > **Unexpected token {**
      
      before any CSS has been applied.
      
      ## How?
      
      Replace the destructuring with individual `var` declarations and replace
      optional chaining with explicit `if` null-checks:
      
      **Before:**
      ```js
      const { href, onload, onerror } = linkTag
      // ...
      () => onload?.call(linkTag, { type: 'load' } as Event),
      () => onerror?.call(linkTag, {} as Event)
      ```
      
      **After:**
      ```js
      var href = linkTag.href
      var onload = linkTag.onload
      var onerror = linkTag.onerror
      // ...
      function () { if (onload) onload.call(linkTag, { type: 'load' } as Event) },
      function () { if (onerror) onerror.call(linkTag, {} as Event) }
      ```
      
      Runtime behavior is identical in all environments. The `var` style was
      intentionally chosen (over splitting `const` declarations) since
      `no-var` is disabled in the project ESLint config.
      
      Fixes #90518
      Co-authored-by: 's avatarsleitor <sleitor@users.noreply.github.com>
      Co-authored-by: 's avatarTim Neutkens <tim@timneutkens.nl>
      ae9c9d6c
    • JJ Kasper's avatar
      Exclude partial fallback for deploy mode (#91163) · e3417906
      JJ Kasper authored
      This feature isn't rolled out so needs to be disabled.
      e3417906
    • Benjamin Woodruff's avatar
      fix: Use a pnpm preinstall script to fix catch-22 in next binary creation (#91016) · 1eab3361
      Benjamin Woodruff authored
      We've had a longstanding issue where you'd have to run `pnpm i` _twice_ on a fresh checkout because `pnpm` wouldn't set up binary symlinks until after the binary exists, but the binary wouldn't exist until after `pnpm build` was done:
      
      https://github.com/vercel/next.js/blob/canary/.github/workflows/build_reusable.yml#L303-L311
      
      This solves that problem using a pnpm preinstall script that creates stub binaries for these files if they don't exist yet (because we haven't run `pnpm build`).
      
      ## Test Plan
      
      ```
      git clean -fxd
      pnpm i
      pnpm build
      pnpm test-start test/e2e/app-dir/next-image/
      pnpm test-start-turbo test/e2e/app-dir/next-image/
      ```
      
      I tested this both locally and inside of a fresh ubuntu VM.
      
      Running `pnpm next` after `pnpm i` but before `pnpm build` gives a helpful error message:
      
      <img width="946" height="125" alt="Screenshot 2026-03-06 at 9 37 14 PM" src="https://github.com/user-attachments/assets/4517e8bd-60ca-44f2-a34c-f7f3ec56c634" />
      1eab3361
    • nextjs-bot's avatar
      v16.2.0-canary.89 · 110ed228
      nextjs-bot authored
      110ed228
    • Will Binns-Smith's avatar
      Trace upload: add git and environment info (#91124) · 51797dbd
      Will Binns-Smith authored
      This adds the following to uploaded trace data:
      
      - Git branch/ref name
      - Whether the trace was uploaded from a Vercel environment
      - Prefers Vercel git environment variable data over running git
      
      Test Plan: Ran a manual test app with EXPERIMENTAL_FLAGS_DEBUG=1, set
      the corresponding environment variables and confirmed they were
      reflected
      51797dbd
    • Steven's avatar
      chore(docs): mention behavior of redirects and remotePatterns (#91151) · bfb8cc7a
      Steven authored
      Some users have been confused by the relationship of
      `images.remotePatterns` and `images.maximumRedirects` so lets document
      it.
      
      This behavior is expected since you might allowlist something like
      `https://github.com/styfle.png` and that can redirect to whatever it
      needs to redirect to (assuming maximumRedirects > 0). For example, it
      currently redirects to
      `https://avatars.githubusercontent.com/u/229881?v=4` but you can imagine
      in the future if the redirect was changed, you wouldn't want your app to
      break.
      
      Regardless of redirects, the final response must be an image.
      
      ---------
      Co-authored-by: 's avatarZack Tanner <1939140+ztanner@users.noreply.github.com>
      bfb8cc7a
    • Sam Selikoff's avatar
      Updates to Instant Navs devtools functionality (#91005) · 19a19a39
      Sam Selikoff authored
      Updates the Instant Navs devtools functionality to use a panel and show
      you two options for capturing the SSR shell or the prefetch for a Client
      navigation.
      
      Replaces current functionality where clicking Instant Navs changed the
      devtools indicator to a blue pending state awaiting the user's next
      navigation.
      
      
      https://github.com/user-attachments/assets/de5c5a40-e836-4719-9517-6d5c6b0aef2c
      19a19a39
    • nextjs-bot's avatar
      v16.2.0-canary.88 · 4271c8b8
      nextjs-bot authored
      4271c8b8
    • Niklas Mischkulnig's avatar
      Turbopack: introduce `ReferenceTypeCondition` (#91101) · c4457849
      Niklas Mischkulnig authored
      Previously, we used `RuleCondition::ReferenceType(ReferenceType)`. But there are some problem with using the type itself as a matcher:
      
      1. the sub types' Undefined variant (like `CssReferenceSubType::Undefined`) always matched all possible variants. So it was actually impossible to match exactly `CssReferenceSubType::Undefined`
      2. variants with more complex types were also impossible to match against, like `ReferenceType::Inner(ResolvedVc<...>)`
      c4457849
  3. 09 Mar, 2026 13 commits
    • nextjs-bot's avatar
      v16.2.0-canary.87 · 92b854dd
      nextjs-bot authored
      92b854dd
    • Benjamin Woodruff's avatar
      docs(turbopack): Copy over turbopack-trace-server docs (#91111) · ae6406af
      Benjamin Woodruff authored
      **Rendered:** https://github.com/vercel/next.js/blob/dd1cc6fba3cff5fbc38dac3ff4426b481bfcbcb5/contributing/turbopack/tracing.md
      
      This is the content from https://turbopack-rust-docs.vercel.sh/tracing_turbopack.html with some minor updates:
      
      - Use GitHub Flavored Markdown for the warning block
      - Some grammar fixes/tweaks
      - Add an extra note about `--release` being important
      - Add a mention of `pnpm next internal trace`
      - Add a link to @timneutkens's youtube video
      - Change the filepath from the old confusingly named `.next/trace.log` to `.next/trace-turbopack`
      - Add a link to https://trace.nextjs.org/
      ae6406af
    • nextjs-bot's avatar
      v16.2.0-canary.86 · 2ecfbfc1
      nextjs-bot authored
      2ecfbfc1
    • Zack Tanner's avatar
      fix: app-page URL normalization (#91121) · 4e2353ed
      Zack Tanner authored
      ## Summary
      
      Fix an App Router request normalization gap where app-page route-module
      requests could keep internal RSC/segment-prefetch URLs in `req.url`.
      
      This could leak paths like:
      
      - `.../.segments/_tree.segment.rsc`
      - `.../__PAGE__.segment.rsc`
      
      into App Router render state and surface through `usePathname()` during
      server rendering.
      
      ## What changed
      
      - Normalize `req.url` in the app-page route-module path after `.rsc` and
      `.segments/*.segment.rsc` pathname normalization.
      
      ## Why
      
      `base-server` already keeps `req.url` in sync after RSC normalization
      ([ref](https://github.com/vercel/next.js/blob/5e11e67759fa38fe67f70790d7bba8c9ff9ba5fd/packages/next/src/server/base-server.ts#L676-L680)),
      but the app-page route-module path only updated `parsedUrl.pathname`.
      
      Since App Router render state seeds its canonical URL from `req.url`,
      that desync could cause internal segment-prefetch paths to be treated as
      the current pathname.
      4e2353ed
    • Zack Tanner's avatar
      partial fallbacks: gate behind experimental flag (#91123) · c0bf4b6f
      Zack Tanner authored
      This puts the partial fallback upgrading feature introduced in
      https://github.com/vercel/next.js/pull/89063 behind a flag to make it
      easier to test the rollout/eventual stabilization in isolation.
      c0bf4b6f
    • Will Binns-Smith's avatar
      Turbopack: Pass hmr_enabled to ImportMetaBinding (#91118) · 5e11e677
      Will Binns-Smith authored
      `is_hot_module_replacement_enabled` was removed from ChunkingContexts.
      Instead, pass it through from CompileTimeInfo when constructing
      ImportMetaBinding during analysis.
      
      Test Plan: CI
      5e11e677
    • Benjamin Woodruff's avatar
      docs(contributing): Update setup in contributing/core/developing.md (#91018) · 15d9b717
      Benjamin Woodruff authored
      A lot of stuff here was slightly out-of-date or not as helpful as it could be.
      
      For the Linux bits, I tested with a fresh Ubuntu image in LXD.
      15d9b717
    • Tobias Koppers's avatar
      Turbopack: implement module.hot.accept(deps, cb) and module.hot.decline(deps) (#90443) · 014b9987
      Tobias Koppers authored
      ### What?
      
      Implements dependency-level HMR accept and decline for Turbopack,
      covering both ESM (`import.meta.turbopackHot`) and CJS (`module.hot`)
      modules.
      
      Previously Turbopack only supported self-accept (`module.hot.accept()`
      with no arguments) and self-decline. This PR adds the full
      dependency-targeted API:
      
      - `module.hot.accept(dep, cb)` / `import.meta.turbopackHot.accept(dep,
      cb)` — single dep
      - `module.hot.accept([depA, depB], cb)` /
      `import.meta.turbopackHot.accept([depA, depB], cb)` — array of deps
      - `module.hot.decline(dep)` / `import.meta.turbopackHot.decline(dep)` —
      single dep
      - `module.hot.decline([depA, depB])` /
      `import.meta.turbopackHot.decline([depA, depB])` — array of deps
      
      ### Why?
      
      Libraries like `react-refresh` and user code often need to accept
      updates for specific dependencies rather than self-accepting the entire
      module. Without this, those HMR patterns fall back to full page reloads
      in Turbopack.
      
      ### How?
      
      **Runtime** (`turbopack-ecmascript-runtime`):
      - Extended `HotState` with `acceptedDependencies`,
      `acceptedErrorHandlers`, and `declinedDependencies` maps (keyed by
      `ModuleId`)
      - Updated `hot.accept()` and `hot.decline()` to handle string and array
      signatures
      - Updated `getAffectedModuleEffects` to check accepted/declined
      dependencies when propagating updates through the module graph
      - Added `'declined'` effect type that throws an `UpdateApplyError`
      - Track `outdatedDependencies` (map of parent → set of updated deps)
      alongside `outdatedModules`
      - In the apply phase, invoke per-dependency accept callbacks with the
      correct outdated deps
      - Use `Set` for `outdatedDependencies` dedup (O(1) vs O(n) lookups)
      
      **Compiler** (`turbopack-ecmascript`):
      - Added `ModuleHotReferenceAssetReference` — a single asset reference
      type for both accept and decline deps, with shared resolve logic for ESM
      (`esm_resolve`) and CJS (`cjs_resolve`)
      - Added `ModuleHotReferenceCodeGen` — generates code that replaces dep
      string literals with resolved module IDs at compile time
      - ESM binding auto-update: when an ESM module accepts a dependency that
      it also `import`s, the compiler wraps the accept callback to re-import
      the namespace variable (`__TURBOPACK__imported__module__<id> =
      __turbopack_import__(<id>)`) before the user callback runs, so ESM
      bindings reflect updated values without needing `require()`
      - Added `import.meta.turbopackHot` as the ESM equivalent of
      `module.hot`, with TypeScript type declarations in
      `packages/next/types/global.d.ts`
      - Static analysis extracts dep strings from
      `module.hot.accept`/`decline` calls; non-analyzable deps emit a warning
      with distinct error codes (`TP1204` for accept, `TP1205` for decline)
      
      **HMR gating** (`CompileTimeInfo`):
      - Added `hot_module_replacement_enabled` flag to `CompileTimeInfo` to
      gate recognition of `module.hot` and `import.meta.turbopackHot` as
      well-known objects
      - Without this flag, production builds would recognize
      `module.hot.accept(...)` and generate HMR-specific code, leading to
      runtime errors
      - Flag set to `true` for dev servers and `false` for production builds
      across Next.js and turbopack-cli entry points
      - `import.meta.turbopackHot` getter is only emitted when HMR is enabled
      
      **Server HMR** (`next-api`, `next-core`):
      - Server-side `compile_time_info` now also sets
      `hot_module_replacement_enabled` so that `module.hot` /
      `import.meta.turbopackHot` are recognized during analysis of server
      modules
      - Server HMR requires the `--experimental-server-fast-refresh` CLI flag;
      the flag is passed through `ProjectOptions` to the Rust side so
      `server_compile_time_info` only enables HMR when appropriate
      
      **Tests** (`test/development/app-dir/hmr-dep-accept/`):
      - ESM single dep accept — verifies parent module is not re-evaluated,
      accept callback fires, ESM bindings auto-update
      - ESM array dep accept — same as above with `accept(['./dep-a',
      './dep-b'], cb)`
      - CJS `module.hot.accept` — pure CJS dep observer pattern with `.cjs`
      files
      - Single dep decline — verifies full page reload occurs
      - Array dep decline — verifies full page reload with
      `decline(['./dep-a', './dep-b'])`
      014b9987
    • Tobias Koppers's avatar
      Improve unsafe code safety documentation in turbo-tasks-backend (#90755) · 6a733742
      Tobias Koppers authored
      ### What?
      
      Improves safety documentation for all `unsafe` code in the
      `turbo-tasks-backend` crate (6 files, comment-only changes).
      
      ### Why?
      
      A comprehensive audit of all 14 files containing `unsafe` code in
      `turbo-tasks-backend` found **no soundness bugs**, but identified
      several safety comments that were incorrect, misleading, or missing
      entirely. Correct safety documentation is critical for maintaining
      unsafe code over time — reviewers and future contributors rely on these
      comments to understand invariants.
      
      ### How?
      
      **Fixes applied (comment-only, no behavior changes):**
      
      1. **`backend/operation/mod.rs`** — Fixed transmute safety comment that
      referenced wrong lifetime names (`'a`/`'l` → `'e`/`'tx`)
      2. **`database/read_transaction_cache.rs`** — Fixed reference to wrong
      struct name (`LmdbBackingStorage` → `ReadTransactionCache`); added
      struct-level doc explaining the field-ordering invariant required for
      drop safety
      3. **`database/startup_cache.rs`** — Added struct-level doc explaining
      the self-referential pattern and field-ordering invariant; improved
      inline safety comment
      4. **`utils/dash_map_multi.rs`** — Added safety justification for
      `unsafe impl Send/Sync` on `RefMut` explaining bucket pointer
      exclusivity
      5. **`backing_storage.rs`** — Added `// Safety:` comments to 6 `unsafe`
      blocks in the `Either` impl that were missing them
      6. **`kv_backing_storage.rs`** — Made the `flush()` safety comment more
      specific about what "finished processing" means
      
      **Audit summary (14 files reviewed):**
      
      | Risk | Category | Files | Verdict |
      |------|----------|-------|---------|
      | HIGH | Lifetime transmutation | 3 | Sound ✓ — comments fixed |
      | MEDIUM | DashMap raw bucket access | 3 | Sound ✓ — Send/Sync docs
      added |
      | LOW | Unsafe trait method contracts | 8 | Sound ✓ — missing comments
      added |
      | NEGLIGIBLE | Test code | 1 | No issues |
      6a733742
    • Tobias Koppers's avatar
      Fix preview tarball script to include @next/swc-linux-x64-gnu (#91099) · 9c939729
      Tobias Koppers authored
      ### What?
      
      Adds `@next/swc-linux-x64-gnu` to the preview tarball patching script
      (`scripts/patch-preview-tarball.mjs`):
      
      1. Adds the package to the `PACKAGES_TO_PATCH` list so its tarball URL
      is fetched.
      2. Adds the package as an explicit dependency in the patched
      `package.json`, in addition to the overrides/resolutions.
      
      ### Why?
      
      The `@next/swc-linux-x64-gnu` native binary package is an optional
      dependency of `next` and may not be installed automatically depending on
      the platform/package manager. When testing preview tarballs (e.g., in CI
      or on Linux environments), the SWC binary needs to be explicitly present
      for Next.js to function correctly. Without this change, preview tarball
      testing on Linux x64 could fail because the native binary isn't resolved
      from the preview build.
      
      Adding it as a direct dependency (not just an override/resolution)
      ensures the package manager actually installs it, since optional
      dependencies from overridden tarballs may not be auto-resolved.
      
      ### How?
      
      - Added `'@next/swc-linux-x64-gnu'` to the `PACKAGES_TO_PATCH` array so
      the script fetches its tarball URL.
      - After writing overrides/resolutions, the script now also adds
      `@next/swc-linux-x64-gnu` as an explicit entry in `pkg.dependencies`
      pointing to the tarball URL.
      Co-authored-by: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
      9c939729
    • Kowyo's avatar
      example: remove duplicate items in .dockerignore (#91079) · 5a226232
      Kowyo authored
      Removed duplicate entries for cache and temporary directories.
      
      ```diff
      - # Cache directories and temporary data
      - .cache/
      - .parcel-cache/
      - .eslintcache
      - .stylelintcache
      - .turbo/
      - .tmp/
      # Cache directories and temporary data
      .cache/
      .parcel-cache/
      .eslintcache
      .stylelintcache
      .swc/
      .turbo/
      .tmp/
      .temp/
      ```
      Co-authored-by: 's avatarJoseph <joseph.chamochumbi@vercel.com>
      5a226232
    • Ethan (Taehoon) Lee's avatar
      docs(localFont): enhance details about using the localFont function (#88189) · 5e4a54ea
      Ethan (Taehoon) Lee authored
      ### What?
      Enhance the documentation about how to use the `localFont` function.
      
      ### Why?
      The Next.js documentation about [local
      fonts](https://nextjs.org/docs/app/getting-started/fonts#local-fonts)
      has insufficient information about where to store the font files and how
      to reference them with the `localFont` function. The lack of detail
      causes confusion like this issue:
      https://github.com/vercel/next.js/issues/76573.
      
      ### How?
      I created a [demo](https://nextjs-localfont-demo.vercel.app/) to
      investigate the behavior of the `localFont` function (source:
      https://github.com/ethn1ee/nextjs-localfont-demo). I confirmed that the
      font files can be located anywhere inside the project, including at
      root, the `src` directory, the `app` directory, and the `public`
      directory, and that they must all be referenced using relative paths.
      
      Fixes #76573
      
      ---------
      Co-authored-by: 's avatarEthan Lee <48551278+ethn1ee@users.noreply.github.com>
      Co-authored-by: 's avatarJoseph <sephxd1234@gmail.com>
      Co-authored-by: 's avatarJoseph <joseph.chamochumbi@vercel.com>
      5e4a54ea
    • Joseph's avatar
      fix: run lerna on a branch (#91092) · 762bff65
      Joseph authored
      Trying to fix: `lerna ERR! ENOGIT Detached git HEAD, please checkout a
      branch to choose versions.` on `set-preview-version.js`
      
      [Slack
      thread](https://vercel.slack.com/archives/C02CDC2ALJH/p1773051154649349)
      762bff65