Type Route

Type Route

  • Docs
  • GitHub
  • v0.6.0

›<Router>

Introduction

  • Getting Started
  • Simple React Example

Guides

  • Code Splitting
  • Complex Route Parameters
  • Custom Link Behavior
  • Custom Query String
  • Data Fetching
  • Nested and Similar Routes
  • No Match (404)
  • Page Layout
  • Preventing Navigation
  • Programmatic Navigation
  • Redirects
  • Rendering Links
  • Route Parameters
  • Scroll Restoration
  • Server Side Rendering
  • Styling of Links for the Currently Active Route
  • Type Route without React
  • Wildcard Routes
  • Previous Release Docs
  • Guide Missing?

API Reference

    <ParameterDefinition>

    • param

    <RouteDefinition>

    • defineRoute
    • extend

    <RouteGroup>

    • createGroup
    • has

    <Route>

    • action
    • href
    • link
    • name
    • params
    • push
    • replace

    <Router>

    • createRouter
    • useRoute
    • RouteProvider
    • routes
    • session

    Types

    • Link
    • QueryStringSerializer
    • Route
    • RouterOpts
    • SessionOpts
    • ValueSerializer

    Miscellaneous

    • noMatch
    • preventDefaultLinkClickBehavior
Edit

<Router>.routes

<Router>.routes: { [routeName: string]: RouteBuilder }

The routes property of a Router object is a map of route names to a RouteBuilder object. The RouteBuilder object is used to construct a specific route which can be interacted with update your application.

Example

const { routes } = createRouter({
  user: defineRoute(
    {
      userId: param.path.string
    },
    p => `/user/${p.userId}`
  )
});

routes.user({ userId: "abc" }).name; // "user"
routes.user({ userId: "abc" }).params; // { userId: "abc" }
routes.user({ userId: "abc" }).href; // "/user/abc"
routes.user({ userId: "abc" }).link;
routes.user({ userId: "abc" }).push();
routes.user({ userId: "abc" }).replace();
← RouteProvidersession →
Type Route is a Type Hero project  ·  Copyright © 2020