- 16 Jul, 2025 18 commits
-
-
nextjs-bot authored
-
Tim Neutkens authored
## What? Adds support for `remarkPlugins: ['remark-gfm']` and `rehypePlugins: ['rehype-slug']`. Previously you had to nest an array like `remarkPlugins: [['remark-gfm']]` but that's a bug, that case is only for passing options. Directly passing the string without options should be allowed. This PR implements that.
-
Wyatt Johnson authored
### What? Optimizes the `buildAppStaticPaths` function performance and extracts a helper function `calculateFallbackMode` to reduce code duplication. ### Why? The `buildAppStaticPaths` function had several performance bottlenecks: 1. **Repeated regex pattern compilation**: Route parameter patterns were being compiled inside the loop for every route, causing unnecessary overhead 2. **Inefficient root parameter lookups**: Using `Array.includes()` for root parameter checks resulted in O(n) lookups for each parameter 3. **Duplicated fallback mode logic**: The same fallback mode calculation was repeated in multiple places, making the code harder to maintain and prone to inconsistencies These inefficiencies became more apparent when processing large numbers of routes with complex parameter structures. ### How? **Performance optimizations:** - Pre-compile regex patterns for route parameters outside the loop and store them in a Map for O(1) lookups - Convert `rootParamKeys` to a Set for O(1) lookup time instead of O(n) array searches - Optimize the fallback parameter collection loop to break early and avoid redundant iterations **Code organization:** - Extract `calculateFallbackMode` helper function to eliminate code duplication - Add comprehensive tests for the new helper function to ensure correctness - Simplify the main loop logic by using the pre-compiled patterns and optimized data structures
-
Janka Uryga authored
`rootParams` was erroring if used in a `'prerender-client'`, but only if we had `fallbackRouteParams`. this is an edge case, but it is technically possible to hit if our compiler checks for using `rootParams` in client code are bypassed. i've also had to split `PrerenderStoreModern` into two types instead of having `type: 'prerender' | 'prerender-client'`. otherwise, typescript would think that the `case 'prerender'` branch wasn't enough to eliminate `PrerenderStoreModern` even though we already handled the `prerender-client` case at the top. this made the `prerenderStore satisfies never` assertion at the bottom fail. This is a bit tricky to explain, so i'm including a [TS playground repro](https://www.typescriptlang.org/play/?#code/C4TwDgpgBAysD2AnCAZCBzAhgYxFAvFAN5SiQBcUA5GMsgHYAmEiAtADYY4hUC+AUGWhwkEALLxmiegWKlwESjToQmLKlAA+1Wi1VTW2dgEtVwDQKGwEyWSORosuLddESp9fvwgAPMEmAoADMAV3psYGN4GQBnFgA3FgB5enYQABUAC2N6dAAKGJtFV2QASkpCxBz0Yn4oeqhjIKgCooA6K3wunRU1NiNTenNS2oax0kzEeAB3KHoIWYBRRCnEPKoAOXhAzHZ2GYhGRpkBsypSuoaBMZjp42BsTJbC0Q6FEaJL8agAeh+obCYOI9PR9QwmM5fcZ-KAAPSgAGFMPQqIFGPAJsYYlBMnooJgsDkADRQdIwKAsVbYu7AJ4AA3SCmoACJdAwDKchsyNFi5tsAfAALZgTCITAAI04pAxViorN6Bk4ThAzJc8tBUm5bTpULGMLy4oggJCwOm0EeRoA1ocJphAoagqIAIQXXUNQHA5Qa9SUT7fb7IYAhaRQZkAdQgVFsOXxUEFkhYMjZ+hYzLd9Wu-o90C97JYHC4uCovvT40DwZk4cj0ZkmCgSu4UGTfTT-qgme+zCCmBC7GAJbbNyKUBidqxQVM2PmiUQpb1-1hAH45w0YW11+KQoEyZj6JbsXSXsg6QDkSPInsoIbY-ZxAmQ7jbBBEjJafAQugnmaqIkKSZBTkdo2uK2xPP4MQxMYkrmkCEDYqWHbtvwAhAA) i'm guessing that `type: 'prerender' | 'prerender-client'` is more complex than a normal discriminator and TS was getting confused, which is why having two separate types solves it.
-
Jiachi Liu authored
-
Sebastian "Sebbie" Silbermann authored
-
Hendrik Liebau authored
When reading a cache entry, we usually check its tags against the recently revalidated tags, and dismiss it, if it has any of those tags. However, this is only needed during dynamic requests, specifically during the rendering that follows a revalidating server action. During the prerender validation in dev mode, we should not discard the cache entries based on the pending revalidation. The concurrently running dynamic rendering will handle discarding and recreating those cache entries. During build-time prerendering, there will never be any pending revalidated tags. This fixes a bug where a different value was rendered when revalidating with a server action and then reloading the page afterwards (or triggering another unrelated revalidating server action).
-
nextjs-bot authored
-
Hendrik Liebau authored
After having revalidated a prerendered route handler, on the subsequent request we must discard the prerendered data from the file system cache, as we already do for pages and fetch caches as well. > [!NOTE] > This PR is best reviewed with hidden whitespace changes.
-
Hendrik Liebau authored
When a server action or `'use cache'` function is defined as a synchronous function, the error message now only marks the function name for better clarity. Previously, the entire function body was marked, which looks fine in small test fixtures, but is pretty messy for larger functions, both in the terminal as well as in the dev error overlay. For anonymous default exports we can't optimize this and are still marking the entire function body, as we don't have a name to refer to. closes NAR-165
-
Hendrik Liebau authored
The `renderToString` function's last usage was removed in #78495.
-
nextjs-bot authored
Co-authored-by:Sebastian Sebbie Silbermann <sebastian.silbermann@vercel.com>
-
Sebastian "Sebbie" Silbermann authored
-
Hendrik Liebau authored
We're splitting the test app routes between two root layouts, one for (partially) static pages that does not wrap its children in a Suspense boundary, and one for dynamic pages that adds a Suspense boundary above `body`, which opts those pages into fully dynamic rendering. Two tests are expected to fail for now, because they revealed bugs related to revalidation, which will be fixed in follow-up PRs: - https://github.com/vercel/next.js/pull/81611 - https://github.com/vercel/next.js/pull/81621 closes NAR-171
-
Hendrik Liebau authored
We want to respect the `__NEXT_EXPERIMENTAL_PPR` and `__NEXT_EXPERIMENTAL_CACHE_COMPONENTS` environment variables in the test apps, so that we can run them locally with these features enabled without needing to modify the config files. So we're removing the requirement that `__NEXT_TEST_MODE` needs to be set at the same time. Usually you don't want to set this variable locally because it also changes other behavior in a few places. This really has no downside, because it was already possible for users to set both variables and affect the flags, and now this can be done with a single variable. It allows us to keep the noise out of the test app's next config files. We're also moving the assignments from the default config into `enforceExperimentalFeatures` to get the nice output when printing the experimental features in the CLI.
-
Prateek Choudhary authored
### What? Updated the documentation to clarify that App Router requires manual locale handling through dynamic route segments and middleware, with examples showing how to implement i18n redirects correctly. ### Why? The App Router doesn't use the i18n configuration in next.config.js like the Pages Router does. Closes NEXT- Fixes #81227 --------- Co-authored-by:
Joseph <joseph.chamochumbi@vercel.com> Co-authored-by:
Joseph <sephxd1234@gmail.com>
-
Jiachi Liu authored
Remove panel ui flag --------- Co-authored-by:RobPruzan <rapruzan@buffalo.edu>
-
Jiachi Liu authored
-
- 15 Jul, 2025 22 commits
-
-
Zack Tanner authored
Upgrades `path-to-regexp` to address backing concerns from `CVE-2024-45296`. As a result, this requires some additional pre-processing on the paths we generate for interception routes, to ensure we pass a compliant value into `path-to-regexp`.
-
JJ Kasper authored
Just fixes up the type and re-exports it so it can be imported directly from `next`. Also fixes test file not being type checked which didn't catch missing optional fields.
-
Wyatt Johnson authored
### What? Optimizes the `generateParamPrefixCombinations` function (previously `filterUniqueRootParamsCombinations`) to generate all unique sub-combinations of route parameters while ensuring partial shells include complete sets of root parameters. ### Why? The previous implementation only generated combinations at the root parameter level, which was insufficient for PPR (Partial Prerendering) shells. PPR needs all possible prefix combinations of route parameters to create effective shells for nested routes. For example, for a route `/[lang]/[region]/[slug]`, we need shells for: - `/[lang]/[region]` (complete root params) - `/[lang]/[region]/[slug]` (full route) Without proper sub-combinations, nested routes couldn't benefit from PPR shell optimization, leading to performance degradation. ### How? - Renamed `filterUniqueRootParamsCombinations` to `generateParamPrefixCombinations` to better reflect its expanded functionality - Added logic to generate all prefix combinations of route parameters, not just root-level combinations - Implemented root parameter validation to ensure partial shells only include complete sets of root parameters - Added comprehensive test coverage for edge cases including undefined parameters, missing keys, and parameter collisions - Optimized the algorithm to skip invalid combinations early when root parameters are incomplete The function now generates prefix combinations systematically while maintaining backward compatibility and preventing invalid partial routes. NAR-159 --------- Co-authored-by:Hendrik Liebau <mail@hendrik-liebau.de>
-
Steven authored
Add a warning to Next.js 15.5 to prepare for Next.js 16 when `images.qualities` is undefined and the user attempted to use set `quality` prop to something other than 75.
-
nextjs-bot authored
-
Benjamin Woodruff authored
Turbopack: Generalize `ImportedBinding` effect creation to avoid as much special-casing of SimpleAssignTarget (#81653) There was some logic here that checked for the existence of `SimpleAssignTarget`, and using that to bail out of `visit_ident`. That doesn't scale well to pattern assignments, but it turns out that we don't need to bail out, we just need to fix the codegen. Without this, https://github.com/vercel/next.js/pull/81654 breaks the test cases.
-
Stojan Dimitrovski authored
Updates the `with-supabase` example to use the new and much faster (when project is configured with asymmetric JWT support) `supabase.auth.getClaims()` function instead of `getUser()`. --------- Co-authored-by:Benjamin Woodruff <benjamin.woodruff@vercel.com>
-
Anas authored
The `patch-next.cjs` script is failing because two of its dependencies, `pack-util` and `build-native`, are missing their CommonJS versions, which are required for compatibility with the current Node.js environment. To fix this, i added the transpiled `pack-util.js` and `build-native.js` files. --------- Co-authored-by:
graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com> Co-authored-by:
Benjamin Woodruff <benjamin.woodruff@vercel.com>
-
JJ Kasper authored
This creates a new workflow to create a release branch and apply the necessary configs to allow releasing from that branch as this is quite common for backports.
-
Hendrik Liebau authored
When running `next build --debug-prerender`, we also want to set the experimental features even if there is no next.config.js file present. This PR also fixes the `cloneObject` function to better handle nested optional object properties, and we're now also freezing and cloning the default config before applying changes to it. > [!NOTE] > This PR is best reviewed with hidden whitespace changes.
-
Cong-Cong Pan authored
During JavaScript profiling, I identified repeated calls to the exclude function in the webpack configuration and implemented caching to optimize it. <img width="2248" height="772" alt="image" src="https://github.com/user-attachments/assets/1fdb03f3-2904-4195-a538-7b1f4646f0f2" /> I tested the performance using the [chakra-ui-docs](https://github.com/SyMind/chakra-ui-docs) repository with the following steps: 1. Execute `pnpm run dev` 2. Wait for the server to be ready (indicated by the 'Ready' message) 3. Run `curl` on the root endpoint (`/`) | | Webpack | Rspack | |-|-|-| |After| Compiled / in 8.3s (2682 modules) | Compiled / in 2.3s (2650 modules) | |Before| Compiled / in 7.8s (2682 modules) | Compiled / in 1983ms (2650 modules) | --------- Co-authored-by:
Benjamin Woodruff <github@benjam.info>
-
sangwook authored
Fixing a bug - Related issues linked using fixes #81130 - 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 What? This PR fixes a bug where Next.js Script components with strategy="beforeInteractive" incorrectly render classname attribute instead of the HTML standard class attribute. Why? The beforeInteractive script strategy in App Router bypassed the existing setAttributesFromProps utility function that properly maps React prop names to DOM attribute names. This caused className props to be directly set as classname attributes in the HTML, which is non-standard and breaks CSS styling. Before (broken): ``` <script classname="example-class" id="example">...</script> ``` After (fixed): ``` <script class="example-class" id="example">...</script> ``` How? 1. Identified the root cause: In /packages/next/src/client/app-bootstrap.ts, the loadScriptsInSequence function manually set attributes using a simple loop that didn't handle DOM attribute name mapping. 2. Applied the fix: - Imported the existing setAttributesFromProps utility function - Replaced the manual attribute setting loop with the proper utility function call - This ensures className → class mapping works correctly 3. Added comprehensive tests: Created e2e tests in /test/e2e/app-dir/script-before-interactive/ that verify: - Single scripts render with correct class attribute - Multiple scripts work correctly - Script execution remains unaffected - Scripts are properly placed in document head Code changes: ``` // Before (buggy) if (props) { for (const key in props) { if (key !== 'children') { el.setAttribute(key, props[key]) //
❌ className becomes classname } } } ``` // After (fixed) ``` if (props) { setAttributesFromProps(el, props) //✅ className becomes class } ``` Fixes #81130 --------- Co-authored-by:JJ Kasper <jj@jjsweb.site>
-
JJ Kasper authored
This ensures if using NextServer or a custom-server directly we honor the custom config passed in correctly.
-
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.
-
BYUNGI authored
Fixes #64910 This PR resolves an issue where a client-side navigation to the root page fails when both `basePath` and `middleware` are active. This is caused by an incorrect redirect loop on the `/_next/data` request. The sequence of events is as follows: 1. Next.js enforces its `trailingSlash: false` policy by adding an internal redirect from `{basePath}/` to `{basePath}`. 2. For middleware to be invoked correctly, a data request for the root page is normalized to `/`. 3. The path is then re-joined with the `basePath` using `path.posix.join(config.basePath, '/')`, which incorrectly results in `{basePath}/`. 4. This malformed path triggers the redirect from step 1, causing the data fetch to fail with a 308 status code and resulting in empty `pageProps`. This fix isolates the root path (`/`) during path normalization to prevent an extra trailing slash from being added. By ensuring the path resolves to `{basePath}` instead of `{basePath}/`, the redirect loop is avoided. The change correctly handles the root path while leaving the logic for all other paths untouched. --------- Co-authored-by:JJ Kasper <jj@jjsweb.site>
-
Niklas Mischkulnig authored
-
Hendrik Liebau authored
When running the following test isolated, and not as part of the full test suite, the owner stacks for async I/O errors were missing the top-most stack frame that's pointing at the `fetch` call. ``` pnpm test-dev test/e2e/app-dir/dynamic-io-errors/dynamic-io-errors.test.ts -t "should show a collapsed redbox with two errors" ``` The same could be reproduced with `pnpm next dev test/e2e/app-dir/dynamic-io-errors/fixtures/default` at http://localhost:3000/dynamic-root, unless http://localhost:3000/static was visited first. The likely reason for that is that React's async I/O tracking was recently optimized for performance reasons in facebook/react#33736 and facebook/react#33737. We can help React a bit with the tracking by explicitly awaiting our `makeHangingPromise` calls. With this fix, the case from above reliably works in isolation.
-
Ankur Datta authored
- A Next.js starter app using [Prisma Postgres](https://www.prisma.io/postgres) and Prisma ORM This PR adds a new example demonstrating how to integrate Prisma ORM with a Next.js application. The example includes: - Setup instructions for Prisma Postgres - Example models and queries - Basic CRUD operations using Prisma --------- Co-authored-by:
Nikolas <nikolas.burk@gmail.com> Co-authored-by:
Alex Martin <alex.martin@vercel.com> Co-authored-by:
JJ Kasper <jj@jjsweb.site>
-
Steven authored
The stale bot comment says 2 years even though its 1.5 years (or 545 days to be precise). The exact amount of time is not as important in this message so we can remove it to avoid drift between the message and actual stale time.
-
Delba de Oliveira authored
Closes: - https://linear.app/vercel/issue/DOC-4841/setup-minimum-working-app-in-the-nextjs-repo - https://linear.app/vercel/issue/DOC-4845/add-community-readme --------- Co-authored-by:
Joseph Chamochumbi <joseph.chamochumbi@vercel.com>
-
Jiachi Liu authored
* The bottom reset button should cover the content * No need for transparent button background | After | Before | |:--|:--| | <video src="https://github.com/user-attachments/assets/598a6474-315a-4ed5-819b-dd49306125ef"> | <video src="https://github.com/user-attachments/assets/9d7ba02c-033e-43b7-a65c-6764e903e10e"> |
-