Skip to Content

page.tsx

page.tsx is a page of the app, shown at the URL of its folder and run in the browser.

app/ ├── page.tsx # / ├── orders/ │ ├── page.tsx # /orders │ └── [id:int]/ │ └── page.tsx # /orders/:id └── (admin)/ └── users/ └── page.tsx # /users

What it does

Every folder with a page.tsx becomes a route. The URL is the folder path without app/, without (group) folders and without the type of a dynamic segment. manh.run builds the route table from the tree; the router is react-router.

Every layout.tsx from the root down to the page’s folder wraps the page.

Exports

  • default: the page’s React component. It takes no props; read URL parameters with useParams() from react-router.
  • meta (optional): title, description, image, noindex. On deploy manh.run writes them into the HTML <head> so search engines and link previews can read them. Literal values only: strings, true, false.

Example

app/orders/[id:int]/page.tsx
import { useParams } from "react-router"; import { PageContainer, ProDescriptions } from "@ant-design/pro-components"; import { useApiClient } from "app/api"; import { useRequest } from "app/hooks"; import { orderColumns } from "../orders-columns"; export const meta = { title: "Order details", noindex: true }; export default function OrderDetailPage() { const { id } = useParams(); const api = useApiClient(); const { data, loading } = useRequest(() => api.orders.detail(Number(id)), { refreshDeps: [id] }); return ( <PageContainer title={`Order #${id}`} loading={loading}> <ProDescriptions column={2} columns={orderColumns} dataSource={data} /> </PageContainer> ); }

Good to know

  • A page with a typed segment is checked before it renders: /orders/abc shows the built-in 404 page. Inside the page, useParams() still returns strings.
  • app/(admin)/page.tsx is invalid because it has the same URL as app/page.tsx. For a page at /admin, use a plain folder app/admin/page.tsx.
  • Static beats dynamic: /orders/stats goes to stats/page.tsx, not [id:int]/page.tsx.
  • Don’t set onBack on PageContainer: the back icon crashes the page. Put a Button with ArrowLeftOutlined above it.
  • Pages don’t import app/db, *.table.ts or manh/env. Data comes through useApiClient().
  • A meta using variables or ${} templates is ignored and check warns seo.dynamic-meta.

Next steps

  • layout.tsx — wrap pages in an app frame with a menu and sign-out.
  • Data fetching — load a page’s data with useApiClient() and useRequest().
  • List pages — build a list page with status tabs, search and paging.
Last updated