Grail - simple React based isomorphic apps framework
With Grail you will need to write frontend code only and you can use ANY backend you like. Grail plays nice with any API - java, python or ruby.
install
npm install grail --save
getting started
Grail architecture is really simple. We use react router to handle isomorphic routing and rendering components. Additionally router triggers actions PromisePipe that fill stores for rendered components.
The very basic example is here
Lets start with general app. The app will consist of two routes Home (/) and Items (/items)
We will use react router thus we have
var Router = ;var Route = RouterRoute; var routes = <Route path="/" name="home" handler=AppComp > <Route name="items" path="items" handler = ItemsComp action=getItems stores=ItemsStore/> </Route>
We need to build up AppComp and ItemsComp.
var React = ;var grail = ;var RouteHandler = RouterRouteHandler;var Link = RouterLink; var AppComp = React; //render Items componentvar ItemsComp = React;
To render Components though we need a ItemsStore to contain Items.
var ItemsStore = grail;
And an action to fill the Store. As Actions we are using PromisePipe
var PromisePipe = ; PromisePipe; //The Action for /items path. Is taking data from async source datavar getItems = ;
And now we need to create and init app with routes:
var app = grail;app; moduleexports = app;
This will be a client.js
and we are exporting an object with middleware property that we can use in our server.
The server will look like:
var express = ;var app = ; app;var clientAppMiddleware = middleware;app; app;console;