Skip to content

founderlab/fl-react-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.
})

About

Server side React rendering for Frameworkstein apps

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •