export interface Route { /** File path to the page component */ filePath: string; /** URL pattern (e.g., "/posts/:id") */ pattern: string; /** URL pathname (e.g., "/posts/123") */ pathname: string; /** Parameter names in order (e.g., ["id"]) */ paramNames: string[]; /** Regex for matching URLs */ regex: RegExp; /** Layout file paths from root to page (for nested layouts) */ layouts: string[]; /** Nearest error convention file — walks up from page dir to root */ errorPath?: string; /** Nearest loading convention file — walks up from page dir to root */ loadingPath?: string; /** Middleware file paths from root to page (like layouts) */ middlewares: string[]; /** Route type: 'page' or 'api' */ type: "page" | "api"; } export interface RouteMatch { /** The matched route */ route: Route; /** Extracted parameters from URL */ params: Record; } /** * Convert file path to URL pattern * Examples: * app/page.tsx -> / * app/about/page.tsx -> /about * app/posts/[id]/page.tsx -> /posts/:id * app/blog/[year]/[month]/page.tsx -> /blog/:year/:month */ export declare function filePathToPattern(filePath: string, appDir: string): { pattern: string; paramNames: string[]; }; /** * Convert URL pattern to RegExp for matching * /posts/:id -> /^\/posts\/([^\/]+)$/ * /docs/*slug -> /^\/docs\/(.+)$/ */ export declare function patternToRegex(pattern: string): RegExp; /** * Recursively discover page and route convention files in the app directory */ export interface DiscoverRoutesOptions { quiet?: boolean; } export declare function discoverRoutes(appDir: string, options?: DiscoverRoutesOptions): Route[]; /** * Match a pathname against discovered routes * Returns the first matching route with extracted parameters */ export declare function matchRoute(pathname: string, routes: Route[]): RouteMatch | null; //# sourceMappingURL=router.d.ts.map