houkou

Teeny tiny router for node and the browser

npm install houkou
2 downloads in the last day
22 downloads in the last week
75 downloads in the last month

Houkou

Teeny tiny router for node and the browser

Overview

Houkou is a very simple (but surprisingly featureful) router written in JavaScript, targeted towards both Node.JS and the browser. It has no external dependencies and currently weighs in at just over a kilobyte uncompressed.

Features

  1. Simple, clear syntax
  2. Named route parameters
  3. Custom parameter regexes
  4. Reverse routing (generate urls from routes)
  5. Fully tested (check test directory)

Documentation

There's not much to be documented, fortunately! The example below should cover just about everything (seriously). There's some tests in the test directory as well if you want some more examples.

Example Usage

var Houkou = require("houkou");
var route = new Houkou("/post/:id/:title", {requirements: {id: "[0-9]+"}});
var params = route.match("/post/123/this-is-an-example-post");
console.log(params);
var url = route.build(params);
console.log(url);

License

3-clause BSD. A copy is included with the source.

Contact

npm loves you