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 # /usersWhat 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 withuseParams()fromreact-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/abcshows the built-in 404 page. Inside the page,useParams()still returns strings. app/(admin)/page.tsxis invalid because it has the same URL asapp/page.tsx. For a page at/admin, use a plain folderapp/admin/page.tsx.- Static beats dynamic:
/orders/statsgoes tostats/page.tsx, not[id:int]/page.tsx. - Don’t set
onBackonPageContainer: the back icon crashes the page. Put aButtonwithArrowLeftOutlinedabove it. - Pages don’t import
app/db,*.table.tsormanh/env. Data comes throughuseApiClient(). - A
metausing variables or${}templates is ignored andcheckwarnsseo.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()anduseRequest(). - List pages — build a list page with status tabs, search and paging.
Last updated