Rendr is a small library that allows you to run your Backbone.js apps seamlessly on both the client and the server. Allow your web server to serve fully-formed HTML pages to any deep link of your app, while preserving the snappy feel of a traditional Backbone.js client-side MVC app.
Getting Started
To see how to use Rendr to build a simple web app, check out the examples repository for a number of different ways to set up a Rendr app.
Check out the blog post for a more thorough introduction to Rendr.
The Premise
We believe there has to be a better way to build rich web apps today. In the last few years, we've seen more of the application moved to the client-side, with JavaScript representations of views, templates, and models. This enables us to build interactive, native-style single-page apps, but splitting your app into two distinct codebases (often using different languages for client and server) also creates challenges for performance, maintainability, and SEO.
The Goals
Rendr is intended to be a building block along the way to this envisioned future of web apps that can be run on either side of the wire according to the needs of your application.
Some specific design goals:
- Write application logic agnostic to environment
- Minimize
if (server) {...} else {...}
- Talk to RESTful API
- Library, not a framework
- Hide complexity in library
- No server-side DOM
- Simple Express middleware
What's Not Included
Express app
Rather than owning your entire Express app, Rendr simply provides some useful middleware that you can mount into your existing Express app.
Asset Bundling
Asset bundling and serving are outside of Rendr's scope. However, it does have some specific requirements for JavaScript packaging to support modules that are accessible in the CommonJS style on both the client and server. The example app uses Stitch for this, though you could also do this with other tools, such as Browserify.
Notes
Rendr uses the native ECMAScript 5 methods Array.prototype.map
, Function.prototype.bind
, Object.create
, etc. If you plan to support older browsers, such as IE<=8, you should include the lovely es5-shim (and es5-sham) libraries as client-side dependencies.
Contributing
We'd love to see what the community can come up with! There are no doubt a number of developers who are tackling this same problem, and we can learn from each other. If you have a bug fix or feature proposal, submit a pull request with a clear description of the change, plus tests.
Rendr was originally developed by @braitz and @spikebrehm, and now has a healthy list of contributors.
Reporting problems and getting help
Please use the issue tracker to report bugs. For support with using rendr, try asking in the Google group or join #rendr on irc.freenode.org.
License
MIT