Ferry
Simple express middleware for server-side routing with React.
npm install ferry
Usage
ferry.route
with your configuration in the express app.use
function to use ferry as middleware.
1. Call var Main = React;var ferry = ;var app = ; app;
ferry.route options
ferry.route
accepts an options object, with 3 required parameters:
parentComponentFactory
is a React factory.htmlPath
is the file path of the layout HTML file.routes
is a JSON array of route objects consisting of apath
andcomponentFactory
.
app;
2. Put "ferryTemplate" (without quotes) in the your HTML file. Ferry replaces this string with the HTML generated by your react component factory.
<!-- ... --> ferryTemplate <!-- ... -->
Running tests
npm test
License
MIT. Copyright (c) Sterling Whitley