router-act
Skill by vercel
Explains how to write end-to-end tests with createRouterAct and LinkAccordion in the Next.js repository. It is for contributors who need to control or assert on router prefetch and navigation requests in Playwright tests.
Install router-act
Built from the published package, never by AI.
git clone --depth 1 https://github.com/vercel/next.js /tmp/next.js && mkdir -p ~/.claude/skills && cp -r /tmp/next.js/.agents/skills/router-act ~/.claude/skills/router-actRun in your terminal. Claude Code loads skills from ~/.claude/skills automatically.
git clone --depth 1 https://github.com/vercel/next.js /tmp/next.js && mkdir -p ~/.gemini/antigravity-cli/skills && cp -r /tmp/next.js/.agents/skills/router-act ~/.gemini/antigravity-cli/skills/router-actAntigravity CLI loads skills from ~/.gemini/antigravity-cli/skills, or .agents/skills for one project.
Skills can run scripts on your machine. Some need an API key: check the README.
About
This skill is a testing guide for the Next.js repository. It describes how to use the createRouterAct utility from test/lib/router-act.ts to intercept router requests such as prefetches, navigations and Server Actions during a test scope. Assertions can check for expected response content with includes, or require that no router requests are made.
The guide also covers LinkAccordion, a pattern that keeps Link components hidden until a test toggles them inside an act scope, so prefetch timing is controlled. It includes hub page patterns, a Playwright fake clock setup for staleness tests, and a list of common causes of flaky tests. The skill is marked internal and not user-invocable, so it targets people working on Next.js tests.
Written from the project's SKILL.md and checked against it.
What it can do
- act API config optionsAsserts with 'no-requests', includes substrings, ordered response lists, or at least one request.
- LinkAccordion patternHides Link components behind a checkbox so prefetches happen only inside act scopes.
- Standard navigation patternToggles the accordion and clicks the link within a single act scope.
- App Shell handlingExplains that act ignores App Shell requests for matching unless includeAppShellRequests is set.
- Hub pagesDescribes dynamically rendered hub pages that let tests navigate away and back to check staleness.
- Fake clock setupShows how to use Playwright's clock API to control Date.now() in segment cache staleness tests.
- Flakiness guidanceLists patterns to avoid, such as browser.back with open accordions and retry or polling timers.
What you need
- Next.js repository test helper at test/lib/router-act.ts
- Playwright
Try asking
- Write an end-to-end test that asserts a prefetch is served from cache with act.
- Add a LinkAccordion hub page to test segment cache staleness.
- Set up a Playwright fake clock for a stale time test.
Good to know
- Marked internal and not user-invocable.
- The block feature is prone to false negatives, so the guide advises against it.
- Responses are buffered until the act scope exits, so a navigation cannot be read within the same scope.
- Using browser.back with open accordions is discouraged except for BFCache tests.
Security check
ANo download-and-run commands, hidden instructions or signs of sending keys out were found.
Checked automatically: .agents/skills/router-act/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work
Inside the skill
-
SKILL.md12 KB
Alternatives to router-act
All alternatives →Runs a 7-stage workflow for auditing, cleaning up and reviewing GitHub repositories, plus competitor analysis. Written for developers who want a repo checked for secrets, junk files and documentation gaps.
Teaches an AI assistant to build, debug and explain Gradio web UIs and ML demos in Python. It covers the core API, components, event listeners, layouts and the MCP server option. Aimed at Python developers who work with Gradio.
Recommends menus, buttons, toolbars and disclosure controls for Apple platforms using Human Interface Guidelines conventions. Built for developers and designers making iOS, iPadOS, macOS or visionOS interfaces. Checks existing project design context before asking questions.
Creates production-ready FastAPI project structures with async patterns, dependency injection, and error handling. It is for developers starting new FastAPI applications or backend API projects.
Analyzes Android apps to find user workflows to expose as AppFunctions, so AI agents and system shortcuts can run them without opening the app UI. Generates Kotlin code and refines KDoc for Android developers.
Creates, edits, validates and runs Agent QA tests, suites and hooks through MCP or CLI. It keeps canonical IDs and schema contracts intact, for developers and QA teams using Agent QA.
Compare with openclaw-github-repo-commander, gradio or hig-components-menus
router-act: common questions
What is createRouterAct used for?
According to the source, createRouterAct lets tests assert on prefetch and navigation responses end to end without coupling to the exact number of requests. It intercepts router requests made during an act scope.
How does LinkAccordion control prefetching?
A Next.js Link prefetches when it enters the viewport. LinkAccordion keeps the Link hidden behind a checkbox until the test toggles it inside an act scope.
Should I use browser.back in these tests?
The source says not to use browser.back to return to pages with opened accordions, because BFCache restores state and causes uncontrolled prefetches. Hub pages are recommended instead.
How do I install router-act?
Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.
Is router-act free?
The code is published under the MIT licence. The service it connects to may have its own pricing.
Is router-act safe to use?
It scores 91 of 100. Grades: maintenance A, licence A, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.
What are alternatives to router-act?
Similar skills: openclaw-github-repo-commander, gradio, hig-components-menus, fastapi-templates.
