universal-router
Version:
Isomorphic router for JavaScript web applications
33 lines (32 loc) • 1.14 kB
TypeScript
/**
* Universal Router (https://www.kriasoft.com/universal-router/)
*
* Copyright (c) 2015-present Kriasoft.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import type { ParseOptions, CompileOptions } from './path-to-regexp.js';
import UniversalRouter from './universal-router.js';
export interface UrlParams {
[paramName: string]: string | string[];
}
export interface GenerateUrlsOptions extends ParseOptions, CompileOptions {
/**
* Add a query string to generated url based on unknown route params.
*/
stringifyQueryParams?: (params: UrlParams) => string;
/**
* Generates a unique route name based on all parent routes with the specified separator.
*/
uniqueRouteNameSep?: string;
}
/**
* Create a url by route name from route path.
*/
type GenerateUrl = (routeName: string, params?: UrlParams) => string;
/**
* Create a function to generate urls by route names.
*/
declare function generateUrls(router: UniversalRouter, options?: GenerateUrlsOptions): GenerateUrl;
export default generateUrls;