New Major Release Beta
Pre-release
Pre-release
This major version changes a few things:
- The
state
prop changes fromstate
touniversalState
to reduce confusion with React state and highlight that it's used for universal rendering. - It's now easier to grab the universal state from the client. Just use the following from client code (in webpack or browserify apps):
import { getUniversalState } from 'react-html-document';
getUniversalState() // will give you object you passed as `universalState` prop in the server.
- For those situations in which you'd rather inject critical css or inline scripts into the page, there's now an easier way to do it without passing in strings in the
scripts
prop array. To take advantage of it, just include an object like this in the scripts array:
const scripts = [{ file: '/path/to/my/file/in/the/server.js' }];
// pass as props to `HTMLDocument`
And the document will inline the js or css found in that path into the page. Note, that this caches the contents of the files in memory for faster access, so only use it for critical css or scripts.
Take a look at the included example-usage-server.js
file for a real-life example.
Enjoy and thanks for your support!