mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #793] [MERGED] fix(app-router): pass searchParams to layout generateMetadata #852
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#852
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/793
Author: @NathanDrake2406
Created: 4/8/2026
Status: ✅ Merged
Merged: 4/10/2026
Merged by: @james-elicx
Base:
main← Head:fix/layout-generatemetadata-searchparams📝 Commits (3)
477032ffix(app-router): pass searchParams to layout generateMetadatacb8051etest: update entry-templates snapshots for searchParams in layout generateMetadata15a3067fix: match Next.js parity for layout generateMetadata searchParams📊 Changes
5 files changed (+174 additions, -112 deletions)
View changed files
📝
packages/vinext/src/entries/app-rsc-entry.ts(+18 -16)📝
tests/__snapshots__/entry-templates.test.ts.snap(+108 -96)📝
tests/app-router.test.ts(+14 -0)➕
tests/fixtures/app-basic/app/layout-metadata-search/layout.tsx(+26 -0)➕
tests/fixtures/app-basic/app/layout-metadata-search/page.tsx(+8 -0)📄 Description
Summary
generateMetadata()was always called withundefinedforsearchParamsbecause thespObj(URLSearchParams → plain object conversion) was constructed after the layout metadata loop — only the page segment received the real query parameters.spObjconstruction to before the layout loop so all layouts receive the same search params object already correctly used by the page.tests/fixtures/app-basic/app/layout-metadata-search/) and a test asserting thatlayout generateMetadata()title reflects the URL query parameter value, not the undefined-fallback default.Root Cause
In
packages/vinext/src/entries/app-rsc-entry.ts, the layout loop called:while the page call (a few lines later) correctly used
spObj. ThespObjvariable simply wasn't constructed yet when the loop ran.Test Plan
layout generateMetadata() receives searchParams from URL query string— verifies?tab=settingsproduces<title>Layout Section: settings</title>from the layout'sgenerateMetadatavp test run tests/app-router.test.ts -t "metadata|generateMetadata|viewport"— 26 tests green)vp checkpasses (format, lint, types)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.