docs: add a Next.js guide page

Merged
KD
5d ago
+786-77

A Next.js developer had to collect the setup from web.mdx, cache.mdx, the skill, and the example. docs/frameworks/nextjs.mdx puts it on one page, from e2e init to CI.

  • One config for both modes (docs/examples/nextjs/e2e.config.ts, typechecked): next dev with reuseExisting locally, next start when CI is set, with next build before e2e run. The config reads CI the way e2e does (packages/core/src/internal/env.ts:10): CI=0 and CI=false mean a local run.
  • Fix Next.js problems: three accordions.
    • The allowedDevOrigins hydration fix moves here from web.mdx, which now links to it.
    • The App Router's empty role="alert" route announcer, which getByRole('alert') also matches.
    • A webpack watchOptions.ignored entry for .e2e/.
  • Start a new app: create-next-app --example …/examples/with-next for npm, pnpm, and bun, and the Next.js with e2e template for Vercel.
  • Navigation and links: the page goes under Platforms, after Web. web.mdx, cache.mdx, and example-projects.mdx link to it. docs/ja/ and docs/zh/ get the page and the same link edits.
  • Skill: skills/e2e/references/setup.md carries the same guidance (plugin copy synced), with a patch changeset for e2e, since the skill ships in the package.

Issue

Closes ENG-1378

Verified

Ran it locally: yes. The steps on the page ran with the published e2e@0.23.1, @e2e-dev/web@0.16.0, and Next.js 16.4.6, in fresh create-next-app projects.

Step on the pageResult
npx e2e init --yes, then the page's config with init's agents kept, npx e2e runpasses, next dev started (ready 1.98s)
dev server already running, npx e2e runreused it, passes
npm run build, then CI=1 npx e2e runnext start started (ready 0.49s), passes
CI=false and CI=0next dev started, as e2e reads them
port 0 (127.0.0.1), a client counter test, no allowedDevOriginsfails: the click never updates the counter, HMR WebSocket errors
same, with allowedDevOrigins: ['127.0.0.1']passes
getByRole('alert') on a page with no alert of its owncount 1: the route announcer
next dev --webpack, a module under .e2e/ changesrebuilds without the page's watchOptions, does not rebuild with them
npx create-next-app --example https://github.com/e2e-inc/e2e/tree/main/examples/with-next, npm run test:e2e3 passed, 2 agent tests skipped without a key
 āœ“ target "web" command at http://localhost:3000/ ready 1.98s
   āœ“ |web| tests/example.e2e.ts > app opens 460ms
      Tests  1 passed (1)

Not verified:

  • The .e2e/ rebuild loop itself. I could not reproduce it on Next.js 15.5 or 16.4, with or without Tailwind, on Turbopack or webpack, in a single run or against a reused dev server. So the accordion is a conditional fix ("when next dev recompiles while the tests run"). Turbopack has no ignore option for it, so the page gives the webpack fix only.
  • The rendered page. mint dev rejects the custom theme in docs/docs.json, so I did not see it on the site. pnpm docs:check compiles every page as MDX and checks anchors, examples, package-manager tabs, and the ja and zh outlines.

Review (fresh context, gpt-6.2-sol): four findings, all fixed.

  • The sample imported ai, which init does not install for None. It now keeps init's model import and agents entry.
  • The port must match in both dev and start.
  • process.env.CI disagreed with e2e on CI=0 and CI=false.
  • The watchOptions list replaced existing rules without saying so.

Notes:

  • ENG-1378 says "App Router route cache", but the fact in cache.mdx is the route announcer. The page covers the announcer.
  • ENG-1379 (making with-next a proper starter) is still open. The command on the page already works. The generated package.json keeps the name e2e-example-with-next, which is ENG-1379's scope.

šŸ¤– Generated with Claude Code