Type Route

Type Route

  • Docs
  • GitHub
  • Feedback

›<RouteDefinition>

Introduction

  • Getting Started
  • Why Type Route?

Guides

  • Simple React Example
  • Nested/Similar Routes
  • No Match (404)
  • Redirects
  • Route Parameters
  • Complex Route Parameters
  • Rendering Links
  • Programmatic Navigation
  • Preventing Navigation
  • Scroll Restoration
  • Server Side Rendering
  • Page Layout
  • Route Components
  • Guide Missing?

API Reference

    <RouteDefinitionBuilder>

    • defineRoute
    • extend

    <Router>

    • createRouter
    • listen
    • getCurrentRoute
    • history
    • routes

    <RouteDefinition>

    • name
    • push
    • replace
    • href
    • link
    • match

    <RouteDefinitionGroup>

    • createGroup
    • has

    TypeScript

    • Route

<RouteDefinition>.replace

<RouteDefinition>.replace(parameters?: RouteParameters): Promise<boolean>

The replace function will replace the current entry in history and if using the "browser" historyType will update the browser's url. If the route has parameters those will need to be provided to the replace function. Returns a Promise which resolves to a boolean indicating whether or not the navigation completed successfully. The only instance where the navigation would not be successful would be if the handler function passed to listen returned false.

Example

const { routes } = createRouter({
  home: defineRoute("/"),
  post: defineRoute({ postId: "path.param.string" }, p => `/post/${p.postId}`)
});

routes.home.replace(); // returns Promise<boolean>
routes.post.replace({ postId: "abc" }); // returns Promise<boolean>
← pushhref →
Copyright © 2019 the Type Route documentation authors.