- 26 Aug, 2025 1 commit
-
-
nextjs-bot authored
-
- 25 Aug, 2025 10 commits
-
-
Ben Gubler authored
I updated the return type of API routes and route handlers from ```ts Promise<Response> | Response | Promise<void> | void ``` to ```ts Promise<Response | void> | Response | void ``` which fixes #82842. <!-- 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 ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### 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 # -->
-
Ben Gubler authored
`config.api.responseLimit` can also be [set to `false`](https://github.com/vercel/next.js/issues/82842#issuecomment-3207638164). Because of the limitations of type inference on JS files, we need to set the type to `boolean`. See https://github.com/vercel/next.js/issues/82842#issuecomment-3207638164 <!-- 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 ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### 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 # -->
-
Ben Gubler authored
-
Ben Gubler authored
[backport] feat: add typesafety with config.typedRoutes to redirect() and permanentRedirect() (#82860) (#83024)
-
Ben Gubler authored
-
Ben Gubler authored
-
Ben Gubler authored
-
Niklas Mischkulnig authored
-
Zack Tanner authored
Backports: - #82900
-
nextjs-bot authored
-
- 20 Aug, 2025 1 commit
-
-
nextjs-bot authored
-
- 19 Aug, 2025 26 commits
-
-
Ben Gubler authored
Co-authored-by:Zack Tanner <1939140+ztanner@users.noreply.github.com>
-
nextjs-bot authored
-
Joseph authored
As this lands and people learn about the new Route Props helpers, I think we will have this period where the TypeScript snippets show the manual typing, but in key places we introduce the helpers usage. We can then follow up updating all TypeScript snippets showing a page, layout or route, to use these. --------- Co-authored-by:
Ben Gubler <nebrelbug@gmail.com> Co-authored-by:
JJ Kasper <jj@jjsweb.site>
-
Madhur Mittal authored
## What? Updated the documentation for `opengraph-image` / `twitter-image` to fix the **Node.js runtime with local assets** example. ## Why? The existing snippet did not type-check cleanly with Next.js 15+ and could confuse developers. This update improves developer experience by ensuring the snippet is immediately usable and accurate. ## How? - Reproduced the example in a fresh Next.js 15+ project. - Updated the docs example to: - Use `readFile` + Base64 encoding instead of invalid file URLs. - Clarify that assets should be placed relative to the project root. - Added an entry to **Version History** noting the update in v15.x. ## Checklist - [x] Ran `pnpm prettier-fix` - [x] Verified formatting & linting (`pnpm build && pnpm lint`) - [x] Documentation guidelines followed - [x] Example verified in a real Next.js 15 project Fixes #75583 & #75625 (if considered same class of issue) --------- Co-authored-by:
Joseph <sephxd1234@gmail.com> Co-authored-by:
Joseph <joseph.chamochumbi@vercel.com>
-
Ben Gubler authored
-
nextjs-bot authored
-
Ben Gubler 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 ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### 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 # -->
-
Ben Gubler authored
Because tsc doesn't infer string literal types in JS files --------- Co-authored-by:JJ Kasper <jj@jjsweb.site>
-
Ben Gubler authored
## Add codemod to migrate from `next lint` to ESLint CLI This PR introduces a new codemod `next-lint-to-eslint-cli` that helps users migrate away from the deprecated `next lint` command to using ESLint directly, in preparation for Next.js 16 where `next lint` will be removed. ### What it does The codemod automates the migration process by: 1. **Updating package.json scripts** - Replaces all `next lint` commands with `eslint` equivalents - Maps Next.js-specific flags (`--strict` → `--max-warnings 0`, `--dir`/`--file` → paths) - Preserves other ESLint-compatible flags - Handles complex scripts with pipes, redirects, and multiple commands 2. **Managing ESLint configuration** - Creates a new flat config (`eslint.config.mjs`) if none exists - Updates existing flat configs to include Next.js rules - Provides guidance for legacy configs that need manual migration 3. **Installing dependencies automatically** - Adds required packages: `eslint`, `eslint-config-next`, `@eslint/eslintrc` - Detects and uses the project's package manager (npm/yarn/pnpm/bun) - Falls back to manual instructions if installation fails ### Usage ```bash npx @next/codemod@latest next-lint-to-eslint-cli . ``` ### Example transformations ```json // Before { "scripts": { "lint": "next lint", "lint:fix": "next lint --fix", "lint:strict": "next lint --strict --dir src" } } // After { "scripts": { "lint": "eslint .", "lint:fix": "eslint --fix .", "lint:strict": "eslint --max-warnings 0 src" } } ``` ### Why this change? - `next lint` is being deprecated and will be removed in Next.js 16 - ESLint v9+ flat config is becoming the standard - Direct ESLint usage provides more flexibility and better ecosystem compatibility - Reduces Next.js maintenance burden of wrapping ESLint functionality The codemod ensures a smooth transition path for existing Next.js projects while following ESLint best practices. -
Benjamin Woodruff authored
Feedback from @feedthejim: - It's scarier than it needs to be, beta builds should be fine for most users. - This is opt-in, so users probably aren't going to use it by accident. - We don't tend to do this level of warning for other feature flags.
-
Benjamin Woodruff authored
## Context We have some publicly documented syntax for configuring webpack loaders here: https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack#configuring-webpack-loaders However, we also have some undocumented features. Specifically, we have two different "condition" concepts, both of which are shown here: https://github.com/vercel/next.js/blob/1766a1aba6a7c92a03c08073114652d61da1a388/packages/next/src/build/swc/index.ts#L836-L860 1. The `conditions` field in the `turbopack` object of the config can be used to specify predicates (defined by file name glob, regex, or content of file) that can be referenced by rules. 2. There are special built-in internal "conditions" that can be matched by passing an object to a `rule` that does not contain a `loader` field. These special conditions allow us to match on some things we couldn't otherwise declare conditions for. This is about improving the current state of #2, which I'm calling here to "webpack loader built-in conditions". Confusingly, there are also very similar conditions used by the resolver context. I'm not changing those, but I've done a tiny bit of work in this PR to better clarify the difference with naming and types. ## This PR - Instead of using an `RcStr`, for these conditions, use an enum. Theoretically that gives us less flexibility, but it makes it way easier to discover, document, and keep track of what built-in conditions we support. I feel that it's very important that we do this because this enum is effectively a public API, and I'd like to document some version of this API in a subsequent PR. - Use the exact union of supported fields in the zod schema and typescript definitions. - Represent the collection of conditions as a set instead of a vec. In reality, this doesn't have much impact because the set is small and always constructed in the same order, but the intent is clearer. Implemented `TaskInput` for `BTreeSet`. - Some minor consistency cleanup between `next_server` and `next_client`. - Get rid of some extra type conversions using the `rcstr!()` macro.
-
Janka Uryga authored
This PR fixes some HTML/RSC stream interleaving logic that, under some circumstances, resulted in hydration of a resumed page being delayed unnecessarily. Fixes NAR-284 --- When SSRing a page, we're mixing two streams -- the HTML stream, and the RSC stream (containing scripts with RSC data, used for hydration). In a regular (non-PPR) render, we need to wait for react to flush the first HTML chunk (containing `<html><body>...`) before we can send the first RSC script. This was implemented in `createMergedTransformStream`. The problem was that `createMergedTransformStream` was also re-used when rendering a PPR `resume()`. In that case, we're only outputting the dynamic portion of HTML, and the shell is sent separately (either by the next server, outside of `app-render`, or by infrastructure), meaning that is _not_ part of the stream that `createMergedTransformStream` receives. But the "wait for the first html chunk" logic was still there, and thus, we were accidentally delaying sending any RSC scripts until the first piece of dynamic HTML was rendered even if they had no connection to each other. In particular, this also prevented us from sending hydration data for the static shell. There's one edge case here -- if we didn't produce a static shell (e.g. for suspense-above-body), we should still apply the html-waiting logic, otherwise we'd end up sending scripts before the body is rendered. But if we have a shell, we shouldn't wait for the HTML at all. This is now solved as follows: 1. During the prerender, we track whether or not a shell (aka "prelude") was produced, and store that information in the postponed state object 2. When resuming, we check whether the prerender had a shell, and if it does, we don't wait for HTML (under the assumption that it was already sent separately, outside the dynamic render) To test this, I've had to extend our testing setup a bit -- with the default settings, playwright would wait until `load` is fired, which seems to fire after all the HTML finished streaming and thus doesn't let us inspect whether partial hydration is working correctly. We're also waiting for `load` in `elementByCss` (apparently, for compatibility with tests written before playwright) so i've had to work around that as well.
-
Ben Gubler authored
- Rename `experimental.typedRoutes` to `typedRoutes` - Remove old references to `typedRoutes` not working with Turbopack - Remove unnecessary encoding of `typedRoutes` for bundlers
-
nextjs-bot authored
Co-authored-by:Sebastian Sebbie Silbermann <sebastian.silbermann@vercel.com>
-
Vercel Release Bot authored
This auto-generated PR updates the production integration test manifest used when testing Rspack.
-
Ben Gubler authored
# Transition from `next lint` to explicit ESLint configs and add Biome support ## What? This PR makes two major changes to Next.js linting: 1. **Transitions away from `next lint`**: `create-next-app` now generates explicit ESLint configurations instead of relying on the `next lint` command 2. **Adds Biome as a linter option**: Users can now choose between ESLint, Biome, or no linter during project setup ## Why? **ESLint Transition**: Provides transparency (users see exact rules), better IDE integration, easier customization, and follows industry standards for explicit configuration. **Biome Support**: Offers a faster, unified linting/formatting tool and gives users more choice in their developer experience. ## How? ### ESLint Configuration Generation - Generates `eslint.config.mjs` files that extend `eslint-config-next` packages - Includes proper ignores for build artifacts (`next-env.d.ts`, `.next/`, etc.) - Package.json scripts call `eslint .` directly instead of `next lint` - Maintains complete feature parity with current `next lint` behavior ### Biome Integration - Added `--biome` flag and interactive prompt selection - Generated `biome.json` configurations with Next.js and React domain rules - Includes both `lint` and `format` scripts for Biome projects ### Linter Selection Interactive prompt offers: **ESLint** (comprehensive rules), **Biome** (fast with fewer rules), **None** (skip linter) ### Deprecation Added deprecation warning to `next lint` command (removed in Next.js 16) ## Testing Added comprehensive test suites for both ESLint and Biome configuration generation across all template variants. This change modernizes Next.js linting while providing users with more choice and transparency.
-
Hendrik Liebau authored
When we're rendering a global error page (something with `<html id="__next_error__">`), we are wrapping the root element in a component that renders a top-level dev overlay to show the global error. The function that's wrapping this element was previously creating an unnecessary second WebSocket connection to handle the case where the error is removed by editing a server component, and the page is subsequently reloaded. However, this can be handled by the first WebSocket connection that's created in the root element just fine, we just need to ensure that the reload is also triggered when `document.documentElement.id` is `'__next_error__'`, which is the same [condition we use for rendering the wrapper](https://github.com/vercel/next.js/blob/a0b7a725a1b424473940fe3111842ae92d918a25/packages/next/src/client/app-index.tsx#L275). This change is covered by existing tests, e.g. `test/development/app-dir/missing-required-html-tags/index.test.ts`.
-
nextjs-bot authored
-
Hendrik Liebau authored
To bypass existing caches when editing server components, we store an HMR hash in a session cookie. The cookie is sent to the server when refetching the RSC, and included in the cache key of all `'use cache'` functions (see #75474). Before this fix, we weren't setting the cookie path properly, which led to multiple cookies for different paths being written and sent to the server. This caused stale values to be used for nested pages, which resulted in stale components being displayed after edits. Now, we set the cookie path to `/`, ensuring that the same cookie is used for all nested pages. closes NAR-204 resolves #81538
-
nextjs-bot authored
-
Niklas Mischkulnig authored
Fixes a panic where we tried to lookup a `Pattern::Alternatives` in a `fallback_import_map.lookup()` (but the API is that the caller is in charge of unwrapping the alternative and calling lookup multiple times). We can completely skip this in this case, because the individual requests inside the `Request::Alternatives` already looked at the `fallback_import_map`, so no need to check again for the whole alternative as well. This was a somewhat recent regression: - https://github.com/vercel/next.js/pull/77954 made sure that `var` variables always have a `<dynamic>` variant added, due to their weird scope rules (or lack thereof). - https://github.com/vercel/next.js/pull/81541 then added a `fallback_import_map`
-
Jiachi Liu authored
-
Jiachi Liu authored
-
Sebastian "Sebbie" Silbermann authored
-
Abhishek Ghimire authored
-
Josh Story authored
[Cache Components] Defer Request Data API resolution to another task in dev when it would suspend when prerendering (#82386) Stacked on #82381 When resolving these Request Data APIs in dev we now do so in a new Task. This allows the environment tracking to properly move stuff that was previously in the Prerender environment to the Server environment when a Request Data API is used before them. This also has the nice side effect of causing these functions to appear as IO in the new suspended-by features of React Devtools. In Prod we don't need to do any additional delaying because the all of the features this is designed to interact with are dev only.
-
- 18 Aug, 2025 2 commits
-
-
Luke Sandberg authored
- Document the experimental persistent caching flag - Document the gap with the `innerGraph` optimization - Document the css module ordering issue - Document the persistent caching gap Will wait to submit this until the when we publish the release.
-
nextjs-bot authored
-