A simple middleware-style router that can be used in both client-side and server-side applications.
- It has simple code with only single path-to-regexp dependency.
- It uses the same middleware approach used in Express and Koa, making it easy to learn.
- It supports both imperative and declarative routing style.
What users say about Universal Router
Just switched a project over to universal-router. Love that the whole thing is a few hundred lines of flexible, easy-to-read code.
-- Tweet by Greg Hurrell from Facebook
It does a great job at trying to be universal — it's not tied to any framework, it can be run on both server and client, and it's not even tied to history. It's a great library which does one thing: routing.
-- Comment on Reddit by @everdimension
npm install universal-router --save
You can find the library in
How does it look like?
const routes =path: '' // optional`<h1>Home</h1>`path: '/posts'consolechildren:path: '' // optional, matches both "/posts" and "/posts/"`<h1>Posts</h1>`path: '/:id'`<h1>Post #</h1>`const router = routesrouter
Books and Tutorials
- 🎓 ES6 Training Course by Wes Bos
- 📗 You Don't Know JS: ES6 & Beyond by Kyle Simpson (Dec, 2015)
- 📄 You might not need React Router by Konstantin Tarkus
- 📄 An Introduction to the Redux-First Routing Model by Michael Sargent
- 📄 Getting Started with Relay Modern for Building Isomorphic Web Apps by Konstantin Tarkus
We support all ES5-compliant browsers, including Internet Explorer 9 and above,
but depending on your target browsers you may need to include
before any other code.
Anyone and everyone is welcome to contribute to this project. The best way to start is by checking our open issues, submit a bug report or feature request, participate in discussions, upvote or downvote the issues you like or dislike, send pull requests.
- #universal-router on Gitter — Watch announcements, share ideas and feedback.
- GitHub Issues — Check open issues, send feature requests.
- @koistya on Codementor, HackHands or Skype — Private consulting.
- React Starter Kit — Boilerplate and tooling for building isomorphic web apps with React and Relay.
- Node.js API Starter Kit — Boilerplate and tooling for building data APIs with Docker, Node.js and GraphQL.
- ASP.NET Core Starter Kit — Cross-platform single-page application boilerplate (ASP.NET Core, React, Redux).
- React App SDK — Create React apps with just a single dev dependency and zero configuration.
- React Static Boilerplate — Single-page application (SPA) starter kit (React, Redux, Webpack, Firebase).
- History — HTML5 History API wrapper library that handle navigation in single-page apps.
- Redux-First Routing — A minimal, framework-agnostic API for accomplishing Redux-first routing.
Become a sponsor and get your logo on our README on Github with a link to your site. [Become a sponsor]
Support us with a monthly donation and help us continue our activities. [Become a backer]