[GH-ISSUE #806] Shim next/root-params module with runtime getters #178

Closed
opened 2026-05-06 12:37:55 +02:00 by BreizhHardware · 0 comments

Originally created by @github-actions[bot] on GitHub (Apr 9, 2026).
Original GitHub issue: https://github.com/cloudflare/vinext/issues/806

Summary

Next.js added generated type definitions for next/root-params, which provides runtime getter functions for root layout parameters. The module already existed at runtime but now has build-time type generation that produces a root-params.d.ts file under .next/types.

Upstream

What changed

  • next/root-params exports async getter functions (e.g., lang(), locale()) for each root param discovered from App Router root layouts
  • Type generation: .next/types/root-params.d.ts is produced during next build, next dev, and next typegen
  • Root params are collected from layout routes in the route types manifest by scanning for the shallowest layout in each branch (root layouts)
  • Params can be string, string[], or undefined depending on whether they're optional, catch-all, or missing from some roots
  • Feature is enabled when experimental.rootParams or cacheComponents is true
  • The generated types are wired into next-env.d.ts via an ESM import

Impact on vinext

vinext needs to:

  1. Add next/root-params to the shim map in resolveId so imports resolve correctly
  2. Implement the runtime module — since vinext scans app/ directories for routing, it can detect root layout params and generate the appropriate getter functions
  3. Consider type generation if vinext supports TypeScript project references or next-env.d.ts equivalent

This is primarily relevant for App Router apps that use root-level dynamic segments (e.g., app/[lang]/layout.tsx). The runtime behavior is the higher priority; type generation can follow later.

Originally created by @github-actions[bot] on GitHub (Apr 9, 2026). Original GitHub issue: https://github.com/cloudflare/vinext/issues/806 ## Summary Next.js added generated type definitions for `next/root-params`, which provides runtime getter functions for root layout parameters. The module already existed at runtime but now has build-time type generation that produces a `root-params.d.ts` file under `.next/types`. ## Upstream - Commit: https://github.com/vercel/next.js/commit/46e2114ea28a39aab4c04c2451aa462af14e62df - PR: https://github.com/vercel/next.js/pull/91019 ## What changed - `next/root-params` exports async getter functions (e.g., `lang()`, `locale()`) for each root param discovered from App Router root layouts - Type generation: `.next/types/root-params.d.ts` is produced during `next build`, `next dev`, and `next typegen` - Root params are collected from layout routes in the route types manifest by scanning for the shallowest layout in each branch (root layouts) - Params can be `string`, `string[]`, or `undefined` depending on whether they're optional, catch-all, or missing from some roots - Feature is enabled when `experimental.rootParams` or `cacheComponents` is true - The generated types are wired into `next-env.d.ts` via an ESM import ## Impact on vinext vinext needs to: 1. Add `next/root-params` to the shim map in `resolveId` so imports resolve correctly 2. Implement the runtime module — since vinext scans `app/` directories for routing, it can detect root layout params and generate the appropriate getter functions 3. Consider type generation if vinext supports TypeScript project references or `next-env.d.ts` equivalent This is primarily relevant for App Router apps that use root-level dynamic segments (e.g., `app/[lang]/layout.tsx`). The runtime behavior is the higher priority; type generation can follow later.
BreizhHardware 2026-05-06 12:37:55 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#178
No description provided.