werkbank
    Preparing search index...

    Function createLinks

    The Router module for the Werkbank framework.

    This module provides a type-safe, schema-based router for React applications. It supports nested routes, search parameter validation (via Valibot), code splitting (lazy loading), and preloading.

    Key exports:

    • createRouter: Factory function to create a router instance.
    • createLinks: Utility to generate type-safe link builders.
    • Link: A type-safe Link component.
    • useNavigation: Hook for programmatic navigation.
    • Creates a type-safe link builder object for the given routes configuration.

      Type Parameters

      • C extends Readonly<{ [route: string]: RouteOption }>

        The routes configuration type.

      Parameters

      • config: C

        The routes configuration object.

      • prefix: string = ""

        An optional path prefix to prepend to all generated links.

      Returns Links<C>

      An object containing link builder functions for each defined route.

      This function generates a nested object structure that mirrors the routes configuration. Each leaf node in the structure is a function that accepts the necessary parameters (path parameters and search parameters) and returns a fully formed URL string.

      const links = createLinks(routesConfig);
      const userUrl = links.users.detail({ params: [123] }); // "/users/123"