Lime Web Components API Documentation - v6.25.0
    Preparing search index...

    Interface RouteRegistry

    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.

    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
    // Registering a simple route
    routeRegistry.registerRoute('/foo', 'foo-component');
    // Registering a route with parameters
    // `name` will be used as a prop on the component when it renders
    routeRegistry.registerRoute('/foo/:name', 'foo-component');
    // 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');
    interface RouteRegistry {
        findComponent(
            path: string,
        ): Required<ComponentDescriptor<string | number>>;
        registerRoute(pathPattern: string, component: string): void;
    }
    Index

    Methods

    • Find the component for a given path.

      Parameters

      • path: string

        The path to match against.

      Returns Required<ComponentDescriptor<string | number>>

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

    • 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