Unobtrusive and ultra-lightweight router library 100% compatible with the Backbone.Router's style for declaring routes, while providing the following advantages:
- Unobtrusive, it is designed from the beginning to be integrated with other libraries / frameworks (also vanilla).
- Great performance, only native functions are used.
- Small footprint, 5kb for minified version.
- No dependencies, no jQuery, no Underscore... zero dependencies.
- Supports both routes' styles, hash and the pushState of History API.
- Proper JSDoc used in the source code.
- Works with normal script include and as well in CommonJS style.
EasyRouter provides methods for routing client-side pages, and connecting them to actions.
¿Want to create a modern hibrid-app or a website using something like React, Web Components, Handlebars, vanilla JS, etc.? ¿Have an existing Backbone project and want to migrate to a more modern framework? Good news, EasyRouter will integrates perfectly with all of those!
Install it via Bower:
bower install easy-router -S
Just use it like the Backbone.Router:
var appRouter = new EasyRouter({
routes: {
'': function () {
...
},
'companies/new': function () {
...
},
'companies/:id': function (id) {
...
},
'signup': function () {
...
},
'login': function () {
...
},
'logout': function () {
...
},
'forgot-password': function () {
...
},
...
}
});
EasyRouter.history.start({pushState: true});