UNPKG

@stacksjs/stx

Version:

A performant UI Framework. Powered by Bun.

31 lines 860 B
/** * Creates a router from a pages directory */ export declare function createRouter(baseDir: string, options?: RouterOptions): Route[]; /** * Matches a URL pathname against routes */ export declare function matchRoute(pathname: string, routes: Route[]): RouteMatch | null; /** * Gets route params from a URL */ export declare function getRouteParams(pathname: string, routes: Route[]): Record<string, string> | null; /** * Pretty prints routes for console output */ export declare function formatRoutes(routes: Route[], baseDir: string): string[]; export declare interface Route { pattern: string regex: RegExp params: string[] filePath: string isDynamic: boolean } export declare interface RouteMatch { route: Route params: Record<string, string> } export declare interface RouterOptions { pagesDir?: string extensions?: string[] }