New advertisers: 50% off your first month with code FIRSTMONTHSee slots
vercel avatar

Router Act

Test prefetch and navigation responses with createRouterAct and LinkAccordion, without flaky timers or request-count coupling.

skills.sh installs
549
GitHub stars
143.6K
last updated
May 16, 2026
View on GitHub

What it does

  • Covers the act API config options, includes matching, App Shell request handling, and the internal intercept-and-buffer flow
  • Includes the LinkAccordion pattern that controls when <Link> components enter the DOM and trigger prefetches
  • Enforces 'no-requests' as the preferred assertion and discourages retry loops, polling timers, and the block feature
  • Designed for end-to-end tests that control internal Next.js requests or assert on their responses

Install

$ npx -y skills add vercel/next.js --skill router-act -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Router Act Testing

Use this skill when writing or modifying tests that involve prefetch requests, client router navigations, or the segment cache. The createRouterAct utility from test/lib/router-act.ts lets you assert on prefetch and navigation responses in an end-to-end way without coupling to the exact number of requests or the protocol details. This is why most client router-related tests use this pattern.

When NOT to Use act

Don't bother with act if you don't need to instrument the network responses — either to control their timing or to assert on what's included in them. If all you're doing is waiting for some part of the UI to appear after a navigation, regular Playwright helpers like browser.elementById(), browser.elementByCss(), and browser.waitForElementByCss() are sufficient.

Core Principles

Details

Repository
github.com/vercel/next.js
Categories
Testing & QA, Frontend & UI Code
First seen
May 16, 2026

More from vercel/next.js

All 14

Similar to Router Act

More Testing & QA