The RouteRegistry service lets you register new locations in the application specified by either a path or a path pattern. Once a location has been registered, it can be navigated to using the Navigator service.

When registering a route, any parameters in the path will be used as props on the component when it is being rendered. Parameters will be of type string, when the parameter can be parsed as a number the type will instead be number. Components that are registered in the RouteRegistry should implement RouteComponent.

Note

Since components are assumed to implement RouteComponent some parameters can not be used as path parameters and some will have special meaning. Special handling will be used for parameters named limetype and id to create a LimeWebComponentContext for the component. id can be used on it's own, but will be used to create context if limetype is also present. The following should not be used since they are part of RouteComponent:

  • platform
  • context
  • query
  • hash
  • state

Example

// Registering a simple route
routeRegistry.registerRoute('/foo', 'foo-component');

Example

// Registering a route with parameters
// `name` will be used as a prop on the component when it renders
routeRegistry.registerRoute('/foo/:name', 'foo-component');

Example

// Registering a route with a context
// The `context` prop of the component will have the values of the
// `limetype` and `id` parameters
routeRegistry.registerRoute('/foo/:limetype/:id', 'foo-component');

Hierarchy

  • RouteRegistry

Methods

  • Find the component for a given path.

    Returns

    the matched component along with path parameters, or undefined if no component could be found.

    Parameters

    • path: string

      The path to match against.

    Returns MatchedComponent

  • Register a route for a component.

    Parameters

    • pathPattern: string

      path pattern used to match a component. For more information about URL patterns read MDN Web Docs.

    • component: string

      Name of the component to register for the specified pattern

    Returns void