Page
Page
renders the content of a single page inside a Layout
. It is identified by the name
prop instead of the old id
prop.
import { Page } from "narraleaf-react";
Basic usage
// Default page for its parent Layout (name = null)
<Page name={null}>
<Home />
</Page>
// Explicit page name
<Page name="detail">
<Detail />
</Page>
When name
is null
(or omitted), the page becomes the default handler of its parent Layout
: it is rendered whenever the layout matches and no other page in the same layout matches.
Props
Prop | Type | Description |
---|---|---|
name? | string | null | Relative path segment of the page. null / undefined makes this page the default handler. |
children | React.ReactNode | Page content |
The component no longer accepts the legacy
id
,className
, orstyle
props. Motion props are passed internally by the framework.
Nesting rules
Layout
cannot be nested inside aPage
.- Another
Page
cannot be nested directly inside aPage
. - Use
Layout
components to create deeper directory structures.
Example with Layout
import { Layout, Page } from "narraleaf-react";
<Layout name="user">
{/* /user */}
<Page name={null}>
<UserHome />
</Page>
{/* /user/profile */}
<Page name="profile">
<UserProfile />
</Page>
</Layout>