Find the component registered for a given path
Matches the path against all registered route patterns and returns the component name and extracted parameters if a match is found.
This is typically used internally by the platform routing system, but can be useful for testing or custom routing logic.
The URL path to match (e.g., '/users/123')
Matched component name and parameters, or undefined if no route matches
import { PlatformServiceName } from '@limetech/lime-web-components';
const routeRegistry = platform.get(PlatformServiceName.RouteRegistry);
routeRegistry.registerRoute('/users/:userId', 'user-profile');
const match = routeRegistry.findComponent('/users/123');
// `undefined` when no registered pattern matches the path
const componentName = match?.name;
// 123, not '123'
const userId = match?.props['userId'];
Register a component for a URL pattern
Maps a URL path pattern to a web component tag name. When navigation occurs to a matching path, the component will be instantiated and rendered with URL parameters passed as props.
The path pattern uses the URLPattern API syntax. Common patterns:
/static - Exact match/users/:id - Named parameter/files/:path* - Wildcard parameter/admin/:section(users|roles) - Enum parameterURL path pattern using URLPattern syntax. See MDN URLPattern docs for pattern syntax details.
Tag name of the web component to render for this route
import { PlatformServiceName } from '@limetech/lime-web-components';
const routeRegistry = platform.get(PlatformServiceName.RouteRegistry);
// Exact match
routeRegistry.registerRoute('/dashboard', 'app-dashboard');
// Named parameters, passed to the component as props
routeRegistry.registerRoute('/users/:userId', 'user-profile');
routeRegistry.registerRoute(
'/posts/:postId/comments/:commentId',
'comment-view'
);
// Wildcard parameter
routeRegistry.registerRoute('/files/:path*', 'file-browser');
// Enum parameter
routeRegistry.registerRoute('/admin/:section(users|roles)', 'admin-panel');
// `limetype` and `id` together give the component a context
routeRegistry.registerRoute('/object/:limetype/:id', 'object-viewer');
Service for registering and routing to web components
The RouteRegistry enables URL-based routing to web components within the Lime platform.
Register URL patterns mapped to component tag names, then navigate to those URLs using Navigator. The routing system will instantiate the component and pass URL parameters as props.
A parameter such as
/users/:userIdis extracted and passed as a prop. A value that parses as a number arrives as anumber, anything else stays astring.A
limetypeparameter builds a LimeWebComponentContext for the component. Anidin the same path joins that context, and both are then removed from the props. Anidwithout alimetypecreates no context and stays an ordinary prop.Reserved Property Names
The following property names are reserved by RouteComponent and cannot be used as path parameters:
platform- The platform instancecontext- The component contextquery- URL query parametershash- URL hash fragmentstate- Navigation stateonTitleChanged- Handler bound to the RouteComponent.titleChanged eventExample: Registering a route and navigating to it