Skip to content

Simple router to match URLs and fire callbacks without pushState.

Notifications You must be signed in to change notification settings

anthonyshort/static-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

static-router

Simple router to match URLs and fire callbacks without pushState. Designed for simple sites who want to structure code using routes but don't need pushState. Borrowed heavily from Backbone's router object. It's a lot better than just throwing everything in a global scope.

Installation

$ component install anthonyshort/static-router

API

var Router = require('static-router');
var router = new Router();

router.route('/welcome', function(){
  alert('Welcome page!');
});

router.route('/profile/:user', function(user){
  console.log(user);
});

router.route('/profile/*', function(){
  console.log('match anything after profile!');
});

License

MIT

About

Simple router to match URLs and fire callbacks without pushState.

Resources

Stars

Watchers

Forks

Packages

No packages published