@archangel63/react-render-server
v0.2.4
Published
Very simple node server that render React app bundle into HTML string
Downloads
62
Readme
What is it?
It's a very simple nodejs server that render React app to HTML string.
Features
- Render React bundle into HTML string;
- Uses React Router V4;
- React Redux support;
- JSS support;
- React Material UI support;
- Static files serving support;
- Made with TypeScript;
- Can be easily builded with Babel;
- Supports Axios on client
Usage example
IMPORTANT! This package requires babel-polyfill for correct work!
Install package with
npm i --save @archangel63/react-render-servercommandCreate your
server.jsfile with the following content: ` require("babel-polyfill");require("@archangel63/react-render-server").run(5001, { baseDir: __dirname, mode: "render" }); `
Run it with
node server.jsPass requests to the
http://localhost:5001with HTTP headerX-LOCAL-HOST: *your api server address*
Options
Option | Possible values | Description
---------|-----------------|--------------
mode | view, render | Sets the work mode of the server. view - server will work with static files and render React to the template. Render - server will only render react app. Default: render
baseDir | string | Root path. Required!
pathToApp | string | Path to your app build. Default: *baseDir*/app/js/bundle.js
useMui | boolean | Adds React Material UI support. Defailt: false
useJss | boolean| Adds JSS support. Default: false
disableRedux | boolean | Removes redux support. Default: false
publicFolder | string | Path to public folder in case you will use this server in view mode.
pathToLog | string | Path to log file. Default: *baseDir*/log.txt
License
MIT
