Skip to content

Shim next/root-params module with runtime getters #806

@github-actions

Description

@github-actions

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    nextjs-trackingTracking issue for a Next.js canary change relevant to vinext

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions