1. 06 Aug, 2025 15 commits
  2. 05 Aug, 2025 16 commits
  3. 04 Aug, 2025 9 commits
    • nextjs-bot's avatar
      v15.4.2-canary.30 · 5d899ef5
      nextjs-bot authored
      5d899ef5
    • Luke Sandberg's avatar
      [turbopack] vibecode a benchmark runner for module-cost (#82287) · cee784de
      Luke Sandberg authored
      # Add automated benchmark runner for module-cost
      
      ## What?
      This PR adds an automated benchmark runner for the module-cost benchmark, allowing for consistent measurement of module loading and execution times.
      
      ## Why?
      
      It is to tedious and error prone to run the benchmark. 
      
      ## Usage
      
      Build `next` and turbopack however you like
      ```
      pnpm i
      pnpm prepare-bench
      pnpm build-webpack (or build-turbopack)
      pnpm benchmark
      ```
      
      ## How?
      
      v0 mostly
      cee784de
    • Benjamin Woodruff's avatar
      Turbopack: Update `jsonc-parser`, dedupe with SWC (#82343) · ba47a7c3
      Benjamin Woodruff authored
      I noticed we had two copies of this library.
      
      There are a few minor API changes (some things that were properties are
      now methods, "message" is now "kind"), and I switched our error type
      over to use `RcStr` since it implements `Clone`.
      ba47a7c3
    • Joseph's avatar
    • nextjs-bot's avatar
    • devin-ai-integration[bot]'s avatar
      docs: Improve Content Security Policy documentation (#80580) · 9d3069ad
      devin-ai-integration[bot] authored
      # Improve Content Security Policy Documentation
      
      This PR comprehensively improves the Next.js Content Security Policy
      (CSP) documentation to address community feedback from Reddit and GitHub
      discussions about gaps in the current documentation.
      
      ## Changes Made
      
      ### 1. Enhanced Nonce Flow Explanation
      - Added detailed section explaining how Next.js automatically detects
      and applies nonces during server-side rendering
      - Clarified the 3-step process: middleware generation → Next.js
      extraction → automatic application
      - Explained that developers don't need to manually add nonces to every
      script tag
      
      ### 2. Static vs Dynamic Rendering Documentation
      - Added comprehensive section explaining performance implications of
      using nonces
      - Documented that nonces force all pages into dynamic rendering
      - Explained trade-offs: slower page loads, increased server load, no CDN
      caching
      - Added guidance on when to use nonces vs alternatives
      
      ### 3. Experimental SRI (Subresource Integrity) Documentation
      - Documented the experimental `sri.algorithm` configuration option
      - Explained hash-based CSP as an alternative to nonces that preserves
      static generation
      - Included configuration examples and benefits/limitations
      - Noted that SRI is webpack-only, App Router only, and experimental
      
      ### 4. Development vs Production Considerations
      - Added section addressing environment-specific CSP requirements
      - Documented need for `'unsafe-eval'` in development for HMR
      - Provided conditional CSP examples based on NODE_ENV
      
      ### 5. Comprehensive Troubleshooting Section
      - Added solutions for error pages that don't work with strict CSP
      - Documented third-party script integration with CSP
      - Included common CSP violation fixes
      - Added examples for both App Router and Pages Router
      
      ### 6. Practical Examples
      - Static site with hash-based CSP using SRI
      - Dynamic site with nonce-based CSP
      - Mixed approach for different page types
      - Environment-aware CSP configuration
      
      ### 7. Enhanced Pages Router Documentation
      - Added `_document.tsx` nonce access example
      - Improved `getServerSideProps` examples
      - Added third-party script integration examples
      
      ## Community Feedback Addressed
      
      This PR directly addresses the Reddit thread feedback about:
      - ❌ "it is not clear that the nonce is then picked up by the rest of the
      pages" → ✅ Added detailed nonce flow explanation
      - ❌ "it is not clear that the pages therefore are not statically
      generated anymore" → ✅ Added static vs dynamic rendering section
      - ❌ "The solution of being able to provide the sha256 hashes... is not
      supported, and it is not mentioned in the documentation" → ✅ Added
      experimental SRI documentation
      - ❌ Poor documentation of strict CSP implementation → ✅ Added
      comprehensive examples and troubleshooting
      
      ## Technical Details
      
      - **File Modified**: `docs/01-app/02-guides/content-security-policy.mdx`
      - **Lines Added**: 642 insertions
      - **Maintains**: Existing documentation structure and Next.js
      conventions
      - **Supports**: Both App Router and Pages Router with appropriate
      switcher components
      
      ## Testing
      
      - Verified all code examples use correct Next.js APIs and patterns
      - Ensured documentation follows existing Next.js docs structure
      - Confirmed all referenced configuration options exist in the codebase
      - Validated that experimental features are properly marked as such
      
      ---
      
      **Link to Devin run**:
      https://app.devin.ai/sessions/e7e5fa95dc0146b3ab79aac72c53ed13
      **Requested by**: lee@vercel.com
      
      ---------
      Co-authored-by: 's avatarDevin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarlee@vercel.com <lee@vercel.com>
      Co-authored-by: 's avatarJoseph Chamochumbi <joseph.chamochumbi@vercel.com>
      9d3069ad
    • Andrew Clark's avatar
      Remove params from segment path (#82249) · 92042340
      Andrew Clark authored
      When performing a segment prefetch, we send a "segment path" to the
      server, which represents the particular segment that we're requesting.
      Originally, I thought these needed to fully encode all the param values,
      but since we already request the segments within the context of a
      particular target page, it's unnecessary — the base URL already contains
      all the param information (and is indeed the source of truth for where
      the param values come from). The only thing we need to put in the paths
      are the param names.
      
      On the client, though, these segments are cached across pages (that's
      the whole point of the Segment Cache). So in the prefetch cache, we do
      need to cache them by their concrete param values.
      
      Splitting out the param names and the param values into separate keys
      will allow us to implement "fallback PPR" behavior for the client, where
      if a segment entry does not reference a particular param, it can be
      reused for all possible values of that param. (We already do this for
      search strings.)
      
      For now, I've split the current "segment path" key into two separate
      keys, which I'm calling the "cache key" and the "request key". It's a
      bit confusing since we have so many different types of cache keys, but I
      think it's OK for now — this will be refactored soon anyway to support
      the fallback PPR behavior.
      
      Despite the line count, most of this PR is just a mechanical refactor.
      Most of it was done by tab completion in Cursor. The substance of the
      change is in the `segment-value-encoding.ts` file.
      92042340
    • PuppyOne's avatar
      docs: add React Developer Tools section for debugging (#82320) · 6e20a10d
      PuppyOne authored
      ## What?
      
      Added a new "React Developer Tools" section to the debugging
      documentation.
      
      ## Why?
      
      This PR resolves #82308 which highlighted that React DevTools - a
      fundamental debugging tool for React applications - was missing from
      Next.js debugging documentation.
      
      Since the Next.js framework is built on React, React DevTools is crucial
      for:
      - Inspecting component hierarchies
      - Debugging state and props
      - Identifying performance issues
      - Understanding application structure
      
      ## How?
      
      Inserted a concise section between "Client-side code" and "Server-side
      code" in
      [docs/01-app/02-guides/debugging.mdx](https://github.com/vercel/next.js/blob/canary/docs/01-app/02-guides/debugging.mdx):
      
      - Introduces developers to the essential React debugging tool and its
      key features
      - Direct users to the corresponding React documentation
      
      ### Checklist: Improving Documentation
      
      - [x] Ran `pnpm prettier-fix` to ensure proper formatting
      - [x] Followed the Docs Contribution Guide:
      https://nextjs.org/docs/community/contribution-guide
      
      
      Closes #82308
      Co-authored-by: 's avatarJoseph <joseph.chamochumbi@vercel.com>
      6e20a10d
    • Niklas Mischkulnig's avatar
      chore: fix eslint-typechecked-require with template (#82328) · 1388270e
      Niklas Mischkulnig 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 #
      
      -->
      1388270e