Expressive router for nodejs and the browser. Rill brings cascading middleware to the browser and enables a familiar routing solution for web applications.
Rill provides the minimum for abstractions over nodejs and the browser enabling things like routing (with redirecting, refreshes and more), cookies, and middleware with the same api.
npm install rill
All modern browsers are supported including IE10 and above. Older browsers will need to polyfill the Promise API, checkout es6-promise for a good polyfill, babel-polyfill also covers this.
- API Documentation
- Middleware List
- Gitter Community
- Reddit Community
- Universal web application framework - Interview with Dylan Piercey
- Browsers, Servers, and APIs
- Why Everyone is Talking About Isomorphic
Rill is the answer to a simple question; Can I run my Express style router in the browser? Turns out you can and it works awesome.
It brings a common interface to many typical app like features in both the browser and nodejs. Many isomorphic frameworks and routers have crazy abstractions and learning curves but with Rill, if you understand Express or Koa, you already know how the routing works! In Rill you get to program much of your application logic using the same api (client or server) including routing, rendering, data fetching and more are easily shared.
How does this thing work?
In the browser it works by listening for internal link clicks, form submissions and browser history changes. It will then create a Rill Context for each of these events and emit it through the router, similar to how receiving a request works in nodejs.
Create an app
/*** The following code can run 100% in the browser or in nodejs.* Examples use es2015/2016 with Babel and JSX but this is optional.*/const app = // You can call Rill without new, but autocomplete will not work.
// Universal form data parsing middleware.app// Universal react rendering middleware.app// Example Loggerapp
Setup a page
// Respond to a GET request.app
Handle a form submission
// Respond to a POST request.app
// Start a regular http server.// In the browser any form submissions or link clicks will intercepted by @rill/http.app
- isbrowser - A browserify transform to remove server-side code.
- isomorphic-fetch - Universal http requests using WHATWG fetch.
- isomorphic-form-data - Send multipart form data universally (able to send files and works with fetch).
- scroll-behavior - @rill/http will automatically try to use the "smooth" scroll-behavior when scrolling to targets on link clicks. This will polyfill that across modern browsers.
- submit-form - Manually trigger Rill navigation in the browser.
- koa-client - Koa clone that runs in the browser, inspired this package.
- monorouter - Another isomorphic router that partially inspired this package.
npm testto build and run tests.