next-roots
Version:
Utility to handle internationalized routing for Next.js app folder.
38 lines (35 loc) • 1.17 kB
TypeScript
// Generated by dts-bundle-generator v9.5.1
export type Route = {
name: `/${string}`;
href: `/${string}`;
};
export type RouteParams = Record<string, string | string[]>;
export type RouterSchema = {
routes: Record<string, Route[]>;
locales: string[];
defaultLocale: string;
};
declare class StaticRouter {
private static LOCALE;
private static PAGE_HREF;
private static PARAMS;
static getLocale(): string;
static setLocale(locale: string): void;
static getPageHref(): Promise<string>;
static setPageHref(pageHref: string): void;
static setParams(params: Promise<Record<string, string>>): void;
}
export declare class Router extends StaticRouter {
private schema;
constructor(schema: RouterSchema);
getHref(name: string, params?: RouteParams): string;
getLocaleFromHref(href: string): string;
getRouteFromHref(href: string): Route | undefined;
private getLocalizedRoutes;
private findRouteByLocaleAndName;
private findRouteByLocaleAndHref;
}
export declare function compileHref(href: string, params: RouteParams): string;
export declare function formatHref(...hrefSegments: string[]): string;
export declare let schema: RouterSchema;
export {};