Skip to content

assertible/react-ssr

Repository files navigation

React js server-side rendering in Haskell

A simple React server-side rendering library for Haskell.

NOTICE Currently this server-side renderer assumes the React application uses Redux and handles store initialization and updates.

Quick start

Render a component using the renderComponent function:

renderComponent
             (defaultSettings "path/to/components")
             False
             "component/Path.js"
             (mkReactProps (A.object ["prop" A..= True]))

Rendering a component w/ caching enabled only involved setting up the cache first:

cc <- newComponentCache
                      1 -- number of stripes
                      2 -- number of cached components per stripe
renderComponent
             (defaultSettings "path/to/components")
             False
             "component/Path.js"
             (mkReactProps (A.object []))

Components are cached based on a serialization of a JSON object containing the component path, the component properties, and the special toStaticMarkup option. For example,

cache_key = SHA1({path: $component_path, props: $component_props, toStaticMarkup: true})

Testing

Ensure you have node & npm installed.

Use the Makefile to bootstrap the react & react-dom node js libraries for testing.

make react react-dom

This is effectively the same as:

cd test/data && npm install react-react-dom

About

React server-side rendering in Haskell with support for Redux

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors