1. 25 Jan, 2026 4 commits
    • nextjs-bot's avatar
      v16.2.0-canary.8 · f4c2d546
      nextjs-bot authored
      f4c2d546
    • Kim Dong Gyu's avatar
      [Reapply] Add `useEffectEvent` to disallowed React APIs in Server Components (#88985) · 7eb2ea49
      Kim Dong Gyu authored
      <!-- Thanks for opening a PR! Your contribution is much appreciated.
      To make sure your PR is handled as smoothly as possible we request that
      you follow the checklist sections below.
      Choose the right checklist for the change(s) that you're making:
      
      ## For Contributors
      
      ### Improving Documentation
      
      - Run `pnpm prettier-fix` to fix formatting issues before opening the
      PR.
      - Read the Docs Contribution Guide to ensure your contribution follows
      the docs guidelines:
      https://nextjs.org/docs/community/contribution-guide
      
      ### Fixing a bug
      
      - Related issues linked using `fixes #number`
      - Tests added. See:
      https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
      - Errors have a helpful link attached, see
      https://github.com/vercel/next.js/blob/canary/contributing.md
      
      ### Adding a feature
      
      - Implements an existing feature request or RFC. Make sure the feature
      request has been accepted for implementation before opening a PR. (A
      discussion must be opened, see
      https://github.com/vercel/next.js/discussions/new?category=ideas)
      - Related issues/discussions are linked using `fixes #number`
      - e2e tests added
      (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
      - Documentation added
      - Telemetry added. In case of a feature if it's used or not.
      - Errors have a helpful link attached, see
      https://github.com/vercel/next.js/blob/canary/contributing.md
      
      
      ## For Maintainers
      
      - Minimal description (aim for explaining to someone not on the team to
      understand the PR)
      - When linking to a Slack thread, you might want to share details of the
      conclusion
      - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
      - Add review comments if necessary to explain to the reviewer the logic
      behind a change
      
      ### What?
      
      ### Why?
      
      ### How?
      
      Closes NEXT-
      Fixes #
      
      -->
      ### What?
      Add `useEffectEvent` to the list of invalid React APIs in Server
      Components.
      
      ### Why?
      Using `useEffectEvent` in a Server Component results in a **runtime
      error**: TypeError: (0 , react_1.useEffectEvent) is not a function.
      Without this fix, developers only discover the mistake at runtime. This
      change improves the **Developer Experience (DX) by catching the error
      immediately in the IDE.**
      
      #### Expected Behavior
      <img width="999" height="566" alt="image"
      src="https://github.com/user-attachments/assets/79c1cbf9-ae0e-4ad7-b163-f650fb289a3a"
      />
      
      #### Currently
      <img width="1708" height="805" alt="image"
      src="https://github.com/user-attachments/assets/a33f73e5-24fd-4405-826a-53f1810154a7"
      />
      <img width="2091" height="812" alt="image"
      src="https://github.com/user-attachments/assets/ed3f191e-a34d-42dd-8779-1d524f6f035d"
      />
      
      ### How?
      - Added `useEffectEvent` to Rust RSC transform
      (`react_server_components.rs`)
      - Added `useEffectEvent` to TypeScript constants (`constant.ts`)
      - Added `useEffectEvent` to error formatting (`format-server-error.ts`)
      - Added test fixture and updated test file
      
      ## Note
      
      This is a reapply of the previous
      [PR](https://github.com/vercel/next.js/pull/88950).
      With help from @timneutkens, I all previously worked code to ensure
      nothing was missed before resubmitting.
      Co-authored-by: 's avatarTim Neutkens <tim@timneutkens.nl>
      7eb2ea49
    • Luke Sandberg's avatar
      [Turbopack] Use a presized scratch buffer for task encoding (#88924) · 1637d617
      Luke Sandberg authored
      ### What
      
      Pass a shared buffer to use as scratch space for encoding TaskStorage values.
      
      Also reduce the size of the `CollectorEntryValue` enum (32->24 bytes), our use of a `SmallVec` was inefficient, instead we can store more inline data by doing it ourselves (22 bytes instead of 16)
      
      ### Why
      
      Currently whenever we encode `TaskStorage` we allocate a new `TurboBincodeBuffer` (aka `SmallVec<[u8;16>`) only the very smallest TaskStorage values fit in that space, so we are always allocating and resizing a buffer for every `TaskStorage` we encode.   Using a shared scratch buffer we avoid resizes and allocations during encoding but now always need to copy our data out of the shared buffer.
      
      This should reduce temporary allocations and buffer copies from the resizes in the common case. As well as ensure that the buffers we pass through to the collectors are exactly sized
      
      I presized it as 4096 bytes since this covers ~98% of tasks we encode, and it is a nice magic number
      
      
      A future optimization could be to accumulate all writes for every SnapshotShard in a single buffer that we pass down to the `Collector`.
      1637d617
    • Jude Gao's avatar
      Improve agents-md prompt to force doc retrieval (#88997) · 39ce0124
      Jude Gao authored
      ## Summary
      
      Updates the instruction in `agents-md` [CLAUDE.md](http://CLAUDE.md)
      output to force LLMs to actually read the docs instead of relying on
      stale pre-training knowledge.
      
      **Before:**
      
      ```
      IMPORTANT: Prefer retrieval-led reasoning over pre-training-led reasoning for any Next.js tasks.
      ```
      
      **After:**
      
      ```
      STOP. What you remember about Next.js is WRONG for this project. Always search docs and read before any task.
      ```
      
      ## Why This Matters
      
      Through systematic testing with the
      [next-evals-oss](https://github.com/vercel/next-evals-oss) eval suite,
      we discovered that the original "prefer retrieval-led reasoning"
      instruction was ineffective. Agents would ignore it and use outdated
      pre-training knowledge (e.g., creating `middleware.ts` instead of the
      new Next.js 16 `proxy.ts` convention).
      
      ## Testing Methodology
      
      We created an "indirect proxy" eval that tests if agents know `proxy.ts`
      is needed for request interception in Next.js 16+, using only the prompt
      "Log every request to the console" (no mention of proxy/middleware).
      
      | Instruction | Pass Rate |
      | --- | --- |
      | "Prefer retrieval-led reasoning" | 0% |
      | "CRITICAL: MUST read docs" | ~20-40% |
      | "What you remember is WRONG" | **100% (6/6)** |
      
      ## Why It Works
      
      The phrase **"What you remember is WRONG"** creates psychological doubt
      in the model's confidence, forcing it to actually read the docs rather
      than trusting its pre-training.
      
      Key elements:
      
      - **"STOP"** - Attention grabber, interrupts default behavior
      - **"WRONG for this project"** - Creates doubt without claiming
      universal wrongness
      - **"Always search docs and read"** - Actionable instruction
      - **"before any task"** - Applies to everything, not just code writing
      
      ## Full Suite Results
      
      - The new indirect-proxy eval passed consistently
      39ce0124
  2. 24 Jan, 2026 4 commits
    • nextjs-bot's avatar
      v16.2.0-canary.7 · f51e3acf
      nextjs-bot authored
      f51e3acf
    • Hanzala Sohrab's avatar
      docs: Update Partytown URLs and package reference (#88928) · d8a0f6ca
      Hanzala Sohrab authored
      - Update Partytown documentation links from `builder.io` to `qwik.dev`.
      - Update Partytown installation package reference in the guide.
      
      <!-- Thanks for opening a PR! Your contribution is much appreciated.
      To make sure your PR is handled as smoothly as possible we request that
      you follow the checklist sections below.
      Choose the right checklist for the change(s) that you're making: -->
      
      ## For Contributors
      
      ### Improving Documentation
      
      - [x] Run `pnpm prettier-fix` to fix formatting issues before opening
      the PR.
      - [x] Read the Docs Contribution Guide to ensure your contribution
      follows the docs guidelines:
      https://nextjs.org/docs/community/contribution-guide
      
      ### Fixing a bug
      
      - [ ] Related issues linked using `fixes #number`
      - [ ] Tests added. See:
      https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
      - [ ] Errors have a helpful link attached, see
      https://github.com/vercel/next.js/blob/canary/contributing.md
      
      ### Adding a feature
      
      - [ ] Implements an existing feature request or RFC. Make sure the
      feature request has been accepted for implementation before opening a
      PR. (A discussion must be opened, see
      https://github.com/vercel/next.js/discussions/new?category=ideas)
      - [ ] Related issues/discussions are linked using `fixes #number`
      - [ ] e2e tests added
      (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
      - [ ] Documentation added
      - [ ] Telemetry added. In case of a feature if it's used or not.
      - [ ] Errors have a helpful link attached, see
      https://github.com/vercel/next.js/blob/canary/contributing.md
      
      
      ## For Maintainers
      
      - [ ] Minimal description (aim for explaining to someone not on the team
      to understand the PR)
      - [ ] When linking to a Slack thread, you might want to share details of
      the conclusion
      - [ ] Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
      - [ ] Add review comments if necessary to explain to the reviewer the
      logic behind a change
      
      ### What?
      Updated Partytown documentation URLs and the installation package
      reference in the `next/script` guide.
      
      ### Why?
      Partytown documentation and packages have moved from `builder.io` to
      `qwik.dev`. The old links were outdated, and the package reference
      needed to be updated to `@qwik.dev/partytown` to ensure users install
      the correct version.
      
      ### How?
      Updated
      [docs/01-app/02-guides/scripts.mdx](cci:7://file:///home/hanzala/Projects/personal/next.js/docs/01-app/02-guides/scripts.mdx:0:0-0:0)
      to replace `partytown.builder.io` with `partytown.qwik.dev` and updated
      the `npm install` instruction.
      
      Closes NEXT-
      Fixes #
      d8a0f6ca
    • Vercel Release Bot's avatar
      Update font data (#88975) · 89cddc26
      Vercel Release Bot authored
      This auto-generated PR updates font data with latest available
      Co-authored-by: 's avatarnextjs-bot <it+nextjs-bot@vercel.com>
      89cddc26
    • Jude Gao's avatar
      feat(next-codemod): add agents-md command for AI coding agents (#88961) · 1e859c06
      Jude Gao authored
      ## Summary
      
      Adds a new `agents-md` subcommand to `@next/codemod` that generates a
      Next.js documentation index for AI coding agents (Claude, Cursor, GitHub
      Copilot, etc.).
      
      ## Usage
      
      ```bash
      # Interactive mode - prompts for version and target file
      npx @next/codemod agents-md
      
      # Non-interactive mode
      npx @next/codemod agents-md --version 15.1.0 --output CLAUDE.md
      
      # Auto-detect version, specify output
      npx @next/codemod agents-md --output AGENTS.md
      ```
      
      ## What it does
      
      1. Downloads the Next.js documentation matching your project's version
      to `.next-docs/` (via git sparse-checkout)
      2. Generates a compact index of all doc files grouped by directory
      3. Injects the index into `CLAUDE.md` or `AGENTS.md` between marker
      comments
      4. Adds `.next-docs/` to `.gitignore`
      
      The index helps AI agents prefer local documentation over pre-trained
      knowledge, ensuring answers match your Next.js version.
      
      ## Options
      
      | Option | Description |
      |--------|-------------|
      | `--version <version>` | Specify Next.js version (auto-detected from
      `package.json` if not provided) |
      | `--output <file>` | Target file path (e.g., `CLAUDE.md`, `AGENTS.md`)
      |
      
      ## Output format
      
      The generated index is a single line with pipe separators:
      
      ```
      <!-- NEXT-AGENTS-MD-START -->[Next.js Docs Index]|root: ./.next-docs|IMPORTANT: Prefer retrieval-led reasoning...|dir:{file1.mdx,file2.mdx}|...<!-- NEXT-AGENTS-MD-END -->
      ```
      
      ## Test plan
      
      - [x] Build passes
      - [x] Tested interactive mode
      - [x] Tested non-interactive mode with `--version` and `--output`
      - [x] Tested auto-detect version with `--output` only
      - [x] Verified `.gitignore` is updated
      - [x] Verified index is injected correctly (new file and existing file)
      
      ## Eval results
      
      Tested against 19 Next.js-specific agent evals with 100% pass rate:
      
      | Eval | Result |
      |------|--------|
      | agent-000-app-router-migration-simple | ✅✅✅ (89.5s) |
      | agent-021-avoid-fetch-in-effect | ✅✅✅ (90.4s) |
      | agent-022-prefer-server-actions | ✅✅✅ (67.1s) |
      | agent-023-avoid-getserversideprops | ✅✅✅ (102.5s) |
      | agent-024-avoid-redundant-usestate | ✅✅✅ (62.9s) |
      | agent-025-prefer-next-link | ✅✅✅ (69.5s) |
      | agent-026-no-serial-await | ✅✅✅ (96.2s) |
      | agent-027-prefer-next-image | ✅✅✅ (68.0s) |
      | agent-028-prefer-next-font | ✅✅✅ (64.2s) |
      | agent-029-use-cache-directive | ✅✅✅ (76.6s) |
      | agent-030-app-router-migration-hard | ✅✅✅ (220.8s) |
      | agent-031-proxy-middleware | ✅✅✅ (92.4s) |
      | agent-032-use-cache-directive | ✅✅✅ (71.3s) |
      | agent-033-forbidden-auth | ✅✅✅ (100.6s) |
      | agent-034-async-cookies | ✅✅✅ (68.7s) |
      | agent-035-connection-dynamic | ✅✅✅ (65.2s) |
      | agent-036-after-response | ✅✅✅ (68.7s) |
      | agent-037-updatetag-cache | ✅✅✅ (70.3s) |
      | agent-038-refresh-settings | ✅✅✅ (71.8s) |
      | **Overall** | **19/19/19 (100%, 100%, 100%)** |
      
      Legend: ✅✅✅ = Build/Lint/Test
      1e859c06
  3. 23 Jan, 2026 20 commits
  4. 22 Jan, 2026 12 commits
    • Jiachi Liu's avatar
      remove gt workflow from agents.md (#88918) · d1616083
      Jiachi Liu authored
      d1616083
    • nextjs-bot's avatar
      v16.2.0-canary.4 · af10864a
      nextjs-bot authored
      af10864a
    • Brooke's avatar
      [prebuilt-skew-protection] feat: adding in automatic deploymentId (#88496) · 7282ce67
      Brooke authored
      Original [PR](https://github.com/vercel/next.js/pull/88012/) has a bug
      that attempted to validate on environment variables. Edited function to
      not run validations on environment variables, only on the user provided
      deployment id.
      
      <!-- Thanks for opening a PR! Your contribution is much appreciated.
      To make sure your PR is handled as smoothly as possible we request that
      you follow the checklist sections below.
      Choose the right checklist for the change(s) that you're making:
      
      ## For Contributors
      
      ### Improving Documentation
      
      - Run `pnpm prettier-fix` to fix formatting issues before opening the
      PR.
      - Read the Docs Contribution Guide to ensure your contribution follows
      the docs guidelines:
      https://nextjs.org/docs/community/contribution-guide
      
      ### Fixing a bug
      
      - Related issues linked using `fixes #number`
      - Tests added. See:
      https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
      - Errors have a helpful link attached, see
      https://github.com/vercel/next.js/blob/canary/contributing.md
      
      ### Adding a feature
      
      - Implements an existing feature request or RFC. Make sure the feature
      request has been accepted for implementation before opening a PR. (A
      discussion must be opened, see
      https://github.com/vercel/next.js/discussions/new?category=ideas)
      - Related issues/discussions are linked using `fixes #number`
      - e2e tests added
      (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
      - Documentation added
      - Telemetry added. In case of a feature if it's used or not.
      - Errors have a helpful link attached, see
      https://github.com/vercel/next.js/blob/canary/contributing.md
      
      
      ## For Maintainers
      
      - Minimal description (aim for explaining to someone not on the team to
      understand the PR)
      - When linking to a Slack thread, you might want to share details of the
      conclusion
      - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
      - Add review comments if necessary to explain to the reviewer the logic
      behind a change
      
      ### What?
      
      ### Why?
      
      ### How?
      
      Closes NEXT-
      Fixes #
      
      -->
      
      ---------
      Co-authored-by: 's avatarvercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
      7282ce67
    • Sebastian "Sebbie" Silbermann's avatar
    • Sebastian "Sebbie" Silbermann's avatar
    • nextjs-bot's avatar
      v16.2.0-canary.3 · 0c196049
      nextjs-bot authored
      0c196049
    • Wyatt Johnson's avatar
      feat: implement LRU cache with invocation ID scoping for minimal mode response cache (#88509) · 092458fd
      Wyatt Johnson authored
      ## Summary
      
      Implements an LRU cache with compound keys for the minimal mode response
      cache to improve cache hit rates during parallel revalidation scenarios.
      
      **Problem**: The previous single-entry cache (`previousCacheItem`) keyed
      by pathname caused cache collisions when multiple concurrent invocations
      (e.g., during ISR revalidation) accessed the same pathname. Each
      invocation would overwrite the previous entry, leading to cache misses
      and redundant work.
      
      **Solution**: An LRU cache using compound keys (`pathname +
      invocationID`) that allows multiple invocations to cache entries for the
      same pathname independently:
      
      ```
      Cache Key Structure
      ─────────────────────
      /blog/post-1\0inv-abc  →  {entry, expiresAt}
      /blog/post-1\0inv-def  →  {entry, expiresAt}
      /blog/post-1\0__ttl__  →  {entry, expiresAt}  (TTL fallback)
      /api/data\0inv-ghi     →  {entry, expiresAt}
      ```
      
      ### Cache Key Strategy
      
      - **With `x-invocation-id` header**: Entries are keyed by invocation ID
      for exact-match lookups (always a cache hit if the entry exists)
      - **Without header (TTL fallback)**: Entries use a `__ttl__` sentinel
      key and validate via expiration timestamp
      
      ### Configuration via Environment Variables
      
      Cache sizing can be tuned via environment variables (using
      `NEXT_PRIVATE_*` prefix for infrastructure-level settings):
      
      | Environment Variable | Default | Description |
      |---------------------|---------|-------------|
      | `NEXT_PRIVATE_RESPONSE_CACHE_MAX_SIZE` | 150 | Max entries in the LRU
      cache |
      | `NEXT_PRIVATE_RESPONSE_CACHE_TTL` | 10000 | TTL in ms for cache
      entries (fallback validation) |
      
      ### LRU Cache Enhancement
      
      Added an optional `onEvict` callback to `LRUCache` that fires when
      entries are evicted due to capacity limits. This enables tracking
      evicted invocation IDs for warning detection without introducing
      timer-based cleanup.
      
      ### Eviction Warnings
      
      When a cache entry is evicted and later accessed by the same invocation,
      a warning is logged suggesting to increase
      `NEXT_PRIVATE_RESPONSE_CACHE_MAX_SIZE`. This helps developers tune cache
      sizes for their workload.
      
      ### Additional Changes
      
      - Renamed header from `x-vercel-id` to `x-invocation-id` for clarity
      - Added `withInvocationId()` test helper for cache testing
      
      ## Test Plan
      
      - Existing response cache tests pass with updated header name
      - Unit tests for `LRUCache` including `onEvict` callback behavior
      - Updated standalone mode tests to use `withInvocationId()` helper
      092458fd
    • Vercel Release Bot's avatar
      Update Rspack production test manifest (#88882) · 4e8671cf
      Vercel Release Bot authored
      This auto-generated PR updates the production integration test manifest used when testing Rspack.
      4e8671cf
    • Niklas Mischkulnig's avatar
    • nextjs-bot's avatar
      v16.2.0-canary.2 · d4e64f52
      nextjs-bot authored
      d4e64f52
    • Tim Neutkens's avatar
      Turbopack: Fix next/font preloading for page.mdx (#88848) · 61bf6f63
      Tim Neutkens authored
      ## What?
      
      This PR fixes font preloading for MDX pages in Turbopack and adds an e2e
      test to verify the fix.
      
      ## Why?
      
      When using `next/font` with MDX pages, font preloading was failing with
      Turbopack because the LoaderTree was storing the **transformed module
      path** instead of the **original source path**.
      
      ## The Bug
      
      In Turbopack, MDX files are transformed by adding a `.tsx` extension:
      - Source file: `app/page.mdx`
      - After transform: `app/page.mdx.tsx`
      
      The `create_module_tuple_code` function in `base_loader_tree.rs` was
      using `module.ident().path()` (the transformed path) instead of the
      original `path` parameter.
      
      This caused a mismatch at runtime:
      - Font manifest key: `[project]/app/page`
      - LoaderTree stored: `[project]/app/page.mdx.tsx`
      - After stripping `.tsx`: `[project]/app/page.mdx`
      - **No match** → fonts not preloaded
      
      ## The Fix
      
      Changed `crates/next-core/src/base_loader_tree.rs` to use the original
      source path:
      
      ```rust
      // Before
      let module_path = module.ident().path().to_string().await?;
      
      // After
      let module_path = path.value_to_string().await?;
      ```
      
      Now the LoaderTree stores `[project]/app/page.mdx`, which after
      stripping `.mdx` at runtime becomes `[project]/app/page`, matching the
      font manifest key.
      
      ## Test
      
      Added `test/e2e/app-dir/mdx-font-preload/` which verifies:
      1. MDX page renders correctly
      2. Font class from layout is applied
      3. Font is correctly preloaded
      
      ## How I tested these changes
      
      ```bash
      pnpm test-start-turbo test/e2e/app-dir/mdx-font-preload/mdx-font-preload.test.ts
      ```
      
      ---------
      Co-authored-by: 's avatarNiklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
      61bf6f63
    • Tim Neutkens's avatar
      Create-next-app update message (#88706) · 85d043a6
      Tim Neutkens authored
      ### What?
      
      This PR fixes `create-next-app` update notifications for prerelease
      versions by checking against the correct npm dist-tag.
      
      ### Why?
      
      Users running `pnpx create-next-app@canary` were incorrectly prompted to
      update to the stable version because:
      
      1. The `update-check` library queries npm's `latest` dist-tag by default
      2. Version comparison using `localeCompare` considers `16.1.1-canary.32`
      less than `16.1.3` (since base version `16.1.1 < 16.1.3`)
      3. This incorrectly triggered an update notification
      
      ### How?
      
      Instead of skipping the update check entirely for prerelease versions,
      this PR:
      
      1. Extracts the dist-tag from the current version (e.g., `canary` from
      `16.1.1-canary.32`)
      2. Passes this as the `distTag` option to `update-check`
      3. Updates the suggested command to include the correct tag (e.g., `pnpm
      add -g create-next-app@canary`)
      
      This ensures:
      - Stable users are notified about newer stable releases
      - Canary users are notified about newer canary releases
      - Beta/RC users are notified about newer versions of their respective
      channels
      Co-authored-by: 's avatarCursor Agent <cursoragent@cursor.com>
      85d043a6