@jay-js/system
Version:
A powerful and flexible TypeScript library for UI, state management, lazy loading, routing and managing draggable elements in modern web applications.
29 lines (28 loc) • 1.09 kB
TypeScript
import type { TRoute, TRouterOptions } from "../types";
/**
* Initializes the router with the specified routes and configuration
*
* The createRouter function is the main entry point for setting up the routing system.
* It processes route definitions, registers them, and triggers the initial route resolution.
*
* @param {Array<TRoute>} routes - Array of route configurations defining the application's routing structure
* @param {TRouterOptions} [options] - Optional configuration options for customizing router behavior
* @throws {Error} Throws an error if no routes are provided and no error handler is configured
*
* @example
* createRouter([
* {
* path: '/',
* element: () => document.createTextNode('Home page'),
* target: document.getElementById('content')
* },
* {
* path: '/about',
* element: () => document.createTextNode('About page')
* }
* ], {
* prefix: '/app',
* onError: (err) => console.error('Router error:', err)
* });
*/
export declare function createRouter(routes: Array<TRoute>, options?: TRouterOptions): void;