Next.js App Router Scaffolding
Use this skill whenever the user asks to add a new route/page/screen to the Next.js app.
Process
- Determine the route segment from the request (e.g. "settings page" →
src/app/settings/). - Check for route groups / parallel routes — if the feature needs auth gating, place it under the existing
(authenticated)route group if one exists; checksrc/app/first. - Create the minimal necessary files — do not generate
loading.tsx/error.tsx/not-found.tsxunless the route does data fetching that can meaningfully be slow or fail:page.tsx— alwayslayout.tsx— only if the segment needs shared chrome distinct from its parentloading.tsx— only ifpage.tsxawaits a data fetcherror.tsx— only ifpage.tsxawaits a data fetch that can throw
- Default to a Server Component for
page.tsx. Fetch data directly in the component withasync function Page(). - If the page needs a form/mutation, create a co-located
actions.tswith a"use server"function, validated withzod, referenced via the node skill conventions for error shape. - Add
generateMetadatawith at leasttitleanddescription. - Wire up navigation — check
src/components/layout/Sidebar.tsxorNav.tsx(if present) and add a link to the new route.
Reference template
See page-template.tsx for the canonical starting structure and actions-template.ts for the Server Action pattern.
Checklist before finishing
- Route follows existing folder/route-group conventions in
src/app/ - Server Component by default,
"use client"only where required -
generateMetadatapresent - Server Actions validate input with
zod - New route linked from navigation if it's a primary feature
- Test added if the route contains non-trivial logic