File conventions

Template file

A default-exported wrapper below a layout, keyed by its segment. State remounts on changes to that segment including dynamic params, not query-only changes. Source: https://nextjs.org/docs/app/api-reference/file-conventions/template. Draft; examples are illustrative snippets, not complete runnable programs.

Formal Syntax & Structure

nextjs syntaxnextjs
app/<segment>/template.tsx

Working Example

Example Snippetnextjs
import type { ReactNode } from "react";export default function Template({children}:{children:ReactNode}) { return <section>{children}</section>; }
Next.js Reference