made with  ♥  by 
React Routing

Routing and navigation solution
for JavaScript applications

12 watchers 488 stars 47 forks 13 open issues

Get Started GitHub View on GitHub
2017-04-20   |   v3.1.0   |   Join #universal-router chat room on Gitter to stay up to date

Universal Router

A simple middleware-style router that can be used in both client-side (e.g. React, Vue.js) and server-side applications (e.g. Node.js/Express, Koa).

Why use Universal Router?

How does it look like?

import Router from 'universal-router';

const routes = [
  {
    path: '/',
    action: () => `<h1>Home</h1>`
  },
  {
    path: '/posts',
    action: () => console.log('checking child routes for /posts'),
    children: [
      {
        path: '/',
        action: () => `<h1>Posts</h1>`
      },
      {
        path: '/:id',
        action: (context) => `<h1>Post #${context.params.id}</h1>`
      }
    ]
  },
];

const router = new Router(routes);

router.resolve('/posts').then(html => {
  document.body.innerHTML = html;
});

Learn more

Sponsors

Does your company use Universal Router in production? Please consider sponsoring this project. Your help will allow maintainers to dedicate more time and resources to its development and support.

Backers

♥ Universal Router? Become a backer to show your support and help us maintain and improve this open source project. Get your image on our README with a link to your site.