fix(app-router): announce committed route changes#2602
Open
NathanDrake2406 wants to merge 3 commits into
Open
Conversation
App Router soft navigations do not expose Next.js route-announcer behavior, so screen readers receive no page-change announcement. Add a shadow-DOM live region tied to the approved visible commit boundary. Skip the initial document load, then announce changed document titles or first-heading text after committed navigations. Cover the initial-empty and soft-navigation behavior with a browser regression based on the upstream Next.js accessibility test.
commit: |
Contributor
Performance benchmarksCompared 0 improved · 0 regressed · 6 within ±1.5%
View detailed results and traces 🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head |
The App Router owns a complete global announcer DOM contract while the Pages Router work introduces another owner for the same custom element. Independent creation and cleanup policies can diverge or remove a node still in use. Move host creation, shadow DOM setup, ARIA configuration, announcement writes, and reference-counted cleanup into a router-neutral client primitive. Keep the App Router visible-commit trigger and accessible-name policy local.
NathanDrake2406
marked this pull request as ready for review
July 13, 2026 09:40
Route announcements still use the approved visible-commit boundary, but the branch has only one DOM announcer consumer. A shared acquisition API and reference counting add a second lifecycle contract without consolidating the separate Pages Router work. Keep host creation and cleanup inside AppRouterAnnouncer to match the Next.js component shape. Remove the unused shared primitive and its implementation-level ownership test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
h1as a fallback, after navigationnext-route-announcershadow-DOM contractWhy
vinext updates the document title during App Router navigation, but it did not expose Next.js's route-announcer live region. A client navigation therefore changed the visible page without announcing that change to assistive technology.
The important lifecycle invariant is that an announcement must describe content the user can actually see. Tying the effect to the generic render ID could announce a render that was later superseded or aborted. This implementation instead reacts to
visibleCommitVersion, vinext's approved visible-commit boundary.What changed
document.title, falling back to the firsth1.Behavior
References
shims/router.ts; this PR covers the separate App Router runtime and has no overlapping files.Verification
The regression was first run without the implementation and failed because the announcer host was absent (
nullinstead of an empty live region).vp checkvp run vinext#buildPLAYWRIGHT_PROJECT=app-router npx playwright test tests/e2e/app-router/nextjs-compat/metadata.spec.tsScope and risk
This is client-only App Router behavior. It adds no dependency, configuration, server, Workers, or public API surface. The live region uses a shadow root to prevent application CSS from changing its accessibility behavior.
Pages Router announcements remain owned by #2571. Focus management and generic navigation-status UI are intentionally out of scope.