UNPKG

@nimpl/router

Version:

Edge router for next.js apps (i18n, basePath, rewrites, redirects)

28 lines (27 loc) 1.03 kB
import { NextResponse } from "next/server"; import { type Redirect } from "./types/changers"; import { type ChangerOptions } from "./types/changers"; export declare class Router { rewrites?: ChangerOptions["rewrites"]; redirects?: ChangerOptions["redirects"]; basePath?: ChangerOptions["basePath"]; i18n?: ChangerOptions["i18n"]; constructor(opts: ChangerOptions); getRequestLocale: (url: URL) => Promise<string | null>; findChanger: <T extends import("./types/changers").RouteChanger[] | Redirect[]>(changers: T, url: URL, routeData: { basePath: string | null | undefined; locale: string | null | undefined; pathname: string; }) => Promise<{ changer: T[number]; groups: { [key: string]: string; }; } | undefined>; parsePathname(pathname: string): { basePath: string | null | undefined; locale: string | null | undefined; pathname: string; }; navigate(nextUrl: URL): Promise<NextResponse<unknown>>; }