Skip to content

Latest commit

 

History

History
61 lines (40 loc) · 2.4 KB

File metadata and controls

61 lines (40 loc) · 2.4 KB

This package has moved to the Frameworkstein repository


Server side renderer function for React, used in Frameworkstein apps

version MIT License PRs Welcome

createServerRenderer

Helper method that takes care of a bunch of boilerplate for rendering react components server side.

Usage:

import _ from 'lodash'
import {createServerRenderer} from 'fl-react-server'
import config from '../config'
import createStore from '../../shared/createStore'
import getRoutes from '../../shared/routes'
import loadInitialState from '../loadInitialState'
import App from '../../shared/modules/app/containers/App'

export default createServerRenderer({
  createStore,                        // Function to create your redux store.

  getRoutes,                          // Function that returns your react-router routes.

  config,                             // Object or function that returns an object. 
                                      // Config gets added to your stores initial state.

  loadInitialState: (req, callback) => callback(null, state),                   
                                      // Function called on each request. 
                                      // You can load up any extra data to place in your store here. 
                                      // It'll be added to the initial state.
  
  omit: 'admin',                      // String or list of strings
                                      // These properties will be omitted from the stores initial state.

  alwaysFetch: App,                   // Component or list of components that will have their 
                                      // fetchData method called on each request.
})