UNPKG

1.07 kBTypeScriptView Raw
1/**
2 * Universal Router (https://www.kriasoft.com/universal-router/)
3 *
4 * Copyright (c) 2015-present Kriasoft.
5 *
6 * This source code is licensed under the MIT license found in the
7 * LICENSE.txt file in the root directory of this source tree.
8 */
9import { ParseOptions, TokensToFunctionOptions } from 'path-to-regexp';
10import UniversalRouter from './UniversalRouter';
11export interface UrlParams {
12 [paramName: string]: string | number | (string | number)[];
13}
14export interface GenerateUrlsOptions extends ParseOptions, TokensToFunctionOptions {
15 /**
16 * Add a query string to generated url based on unknown route params.
17 */
18 stringifyQueryParams?: (params: UrlParams) => string;
19}
20/**
21 * Create a url by route name from route path.
22 */
23declare const generateUrl: (routeName: string, params?: UrlParams) => string;
24declare type GenerateUrl = typeof generateUrl;
25/**
26 * Create a function to generate urls by route names.
27 */
28declare function generateUrls(router: UniversalRouter, options?: GenerateUrlsOptions): GenerateUrl;
29export default generateUrls;