How to use the universal-router/generateUrls function in universal-router

To help you get started, we’ve selected a few universal-router examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github daixianceng / react-universal-example / src / router.js View on Github external
const router = new UniversalRouter(routes, {
  baseUrl: process.env.APP_BASE_URL,
  resolveRoute(context, params) {
    if (typeof context.route.load === 'function') {
      return context.route
        .load()
        .then(action => action.default(context, params));
    }
    if (typeof context.route.action === 'function') {
      return context.route.action(context, params);
    }
    return undefined;
  },
});

export const toUrl = generateUrls(router, {
  stringifyQueryParams: queryString.stringify,
});
export default router;

universal-router

Isomorphic router for JavaScript web applications

MIT
Latest version published 10 months ago

Package Health Score

73 / 100
Full package analysis