Router Object

This module exposes APIs to perform routing side-effects via page.js.

Normally you wouldn't want to reach out to this directly. A better approach would be to restrict routing side-effects to your route handlers, in which case they'd access these APIs through the decorations provided by withRoutingAPIs.

However, in the case that you happen to need to interact with the router outside of a handler's context, you can use these APIs.

Static Methods

    transitionTo(pathname: String) -> void

    Transition to a different page.

    Parameters (1)

    pathname
    String

    Return Value

    void

    redirectTo(pathname: String) -> void

    Transition to a different page and replace the current history entry.

    Parameters (1)

    pathname
    String

    Return Value

    void

    updateQuery(partialQuery: Object) -> void

    Partially update the queryString according to a set of rules:

    • any item that evaluates to undefined, null, or false will be removed from the queryString
    • any item that already exists will be overriden with the next value

    If the behaviour of discarding "falseys" is undesired, look into using Router.replaceQuery instead.

    Parameters (1)

    partialQuery
    Object

    A partial set of query parameters that will be combined with (or override) the existing ones.

    Return Value

    void

    replaceQuery(nextQuery: Object) -> void

    Replace the queryString fully with the next representation. null values will be removed from the resulting queryString.

    Parameters (1)

    nextQuery
    Object

    Your query parameters.

    Return Value

    void