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

tsx
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.

Référence

Signatures

ts
(props: RouterProps): KuitoNode

Paramètres

NomTypeRequisDescription
propsRouterPropsOui—

Retourne

KuitoNode

Props: RouterProps

Props (props héritées incluses) 3

NomTypeRequisDescription
initialDestination<unknown>NonThe first screen shown; the first route's by default.
linkingbooleanNonDeep 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.
childrenKuitoNodeOui—
Généré depuis les déclarations TypeScript publiques : signatures, props et valeurs par défaut viennent de la source vérifiée, les descriptions de sa JSDoc. Aucune valeur par défaut n'est inventée.