Type alias RouteConfig<T>

RouteConfig<T>: Record<string, T>

Route configuration. This is a plain object that associates route path templates to values. Route path templates may contain parameters by using : as a prefix. For example:

const routeConfig: RouteConfig = {
"/": "Home",
"/login": "Login",
"/user/:id": "UserProfile"
};

Type Parameters

  • T extends string = string

    to restrict values to specific strings. For example:

    type Page = 'Home' | 'Login' | 'UserProfile';

    export const routeConfig: RouteConfig<Page> = {
    '/': 'Home',
    '/login': 'Login',
    '/user/:id': 'UserProfile'
    };

    export const router = createRouter({ routeConfig });

    This will provide auto-suggest and type safety for route values.

    router.toRoute('invalid') // error
    router.toUrl('invalid') // error

Generated using TypeDoc