telaviv
v0.1.13
Published
Node.JS React Frontend Server
Downloads
10
Readme
Features
- Universal React:
Renders your components on the server-side and continues rendering on the client-side - HTML5 and AMPHTML:
Supports normal HTML5 web-applications and mobile-optimised AMPHTML.
Idea
The main idea for TelAviv.js is to render a React app initially on a Node.js server and continue further rendering in the user's browser. The next route changes will only request data from the API.
Why?
This concept combines the benefits of server rendering and client rendering:
- Search Engine optimized:
The TelAviv.js server fetches all data from yourREST-API
before responding. So crawlers are able to index all your pages. - Fast initial load:
The TelAviv.js server renders statichtml
markup including the minimal set ofcss
. All JavaScript code gets loaded asynchronous. - Minimal server traffic:
After the JavaScript code was loaded, the TelAviv.js script handles all route changes and only loads data from the API, which relieves the server.
Installation
npm install telaviv --save
Usage
Basically TelAviv.js is a express middleware.
import telaviv from 'telaviv'
import express from 'express'
import config from 'config.js'
let app = express()
app.use(telaviv(config))
app.listen(8080)
config.js
export default {
routes: [{
path: '/article/:id',
html5: [{
component: 'Header'
}, {
component: 'Article',
data: {
type: 'REST',
url: '/api/article/:id'
}
}, {
component: 'Footer'
}]
}],
apiAddress: 'http://localhost:8000/'
}
Contribute
We actively welcome pull requests.
License
TELAVIV.JS is MIT licensed.
Created with ♥ by Dustin Hoffner.