Skip to main content
@usenarrator/plugin-nextjs The Next.js plugin reads a file by where it lives. app/blog/[slug]/page.tsx is “the page at /blog/:slug”, a route.ts file answers requests to its route, and proxy.ts or middleware.ts runs before matching requests reach the app. Inside those files it explains the request APIs, server actions, caching and navigation.
nextjs() returns two plugins: the Next.js rules and a React plugin that also knows next/link, next/image, next/script and next/form. Spread it into your plugin list, or pass the array as it is, since plugins accepts nested arrays. Don’t add react() as well. Installing @usenarrator/plugin-nextjs installs @usenarrator/plugin-react with it. The plugin declares library: { name: "next", versions: ">=13.4 <17" }. Pages and layouts are recognized from their path alone. Everything else, such as request APIs, caching and navigation, is only narrated in files that import from next or belong to a package that depends on it (see Dependency detection).

Routes come from file paths

Routes are read from the path the host passes to narrate, which is e.path inside the engine. The CLI and the browser extension pass repository-relative paths, so this works without any setup. Route groups, parallel routes and intercepting segments are dropped from the route, and dynamic segments use the matcher notation from Next.js. The same mapping is exported as fileInfo(path), which returns the router, the kind of file and the route, or null for files that aren’t Next.js conventions.

Examples

A dynamic page
English
A route handler
English
A server action
English
The proxy (middleware)
English

What it covers

  • File conventions for the App Router and the Pages Router: pages, layouts, the root layout, loading and error screens, not-found, route handlers, API routes, proxy.ts and middleware.ts.
  • Page data: params and searchParams, generateStaticParams, generateMetadata, metadata, and segment config such as revalidate, dynamic and runtime.
  • Route handlers and the request APIs: NextResponse, cookies(), headers(), nextUrl.searchParams, redirects and rewrites, and the proxy’s matcher.
  • Server actions ("use server"), "use cache", cacheTag, cacheLife, revalidatePath, revalidateTag (including the Next.js 16 cache profile form) and updateTag.
  • Navigation: notFound, redirect, useRouter, usePathname, useSearchParams, next/dynamic and the Link, Image, Script and Form elements.

Options

Translating

The English phrasebook is exported as en and typed as NextPhrases. The bundled React plugin keeps its own phrasebook, ReactPhrases.