Router
Die Übersetzung dieser Seite fehlt oder ist veraltet, daher wird sie auf Englisch angezeigt. Auf Englisch lesen
Own the app navigation tree. With component routes you write it in app.tsx; with file routes the compiler generates it from app/.
Declare a home and detail stack
import { Link, Route, Router, Text, VStack, routes, type RouteTo, type ScreenProps } from 'kuito';
declare module 'kuito' {
interface Routes {
index: RouteTo;
show: RouteTo<{ id: number }>;
settings: RouteTo;
}
}
function Home() {
return (
<VStack padding={16}>
<Link to={routes.show({ id: 42 })}>
<Text>Show 42</Text>
</Link>
</VStack>
);
}
function Show({ id }: ScreenProps<{ id: number }>) {
return <Text padding={16}>{`Show ${id}`}</Text>;
}
function Settings() {
return <Text padding={16}>Settings</Text>;
}
export default function App() {
return (
<Router>
<Route name="index" path="/" screen={Home} title="Home" />
<Route
name="show"
path="/show/:id"
params={{ id: Number }}
screen={Show}
title={({ id }) => `Show ${id}`}
/>
<Route name="settings" path="/settings" screen={Settings} presentation="sheet" />
</Router>
);
}Behavior
Use one Router per app. Route parameters are typed; route names identify destinations. An app with file routes writes no Router: its route files and layout are the tree. kuito create --routes components starts an app whose app.tsx is one, with the routes typed by a declare module 'kuito' block.
Continue
Read Navigation for a complete workflow. See the complete prop reference for types and documented defaults.
Referenz
Signaturen
(props: RouterProps): KuitoNodeParameter
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
props | RouterProps | Ja | — |
Rückgabe
Props: RouterProps
Props (einschließlich geerbter Props) 3
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
initial | Destination<unknown> | Nein | The first screen shown; the first route's by default. |
linking | boolean | Nein | Deep links: the link that launched the app, and each one that arrives while it runs, navigate to the route their path matches. Off by default. |
children | KuitoNode | Ja | — |
Generiert aus den öffentlichen TypeScript-Deklarationen: Signaturen, Props und Standardwerte stammen aus der geprüften Quelle, Beschreibungen aus deren JSDoc. Kein Standardwert ist erfunden.