getServerState()
const serverState = await getServerState(children: ReactNode, { renderToString?: (node: ReactElement) => unknown, })
1
import { getServerState } from 'react-instantsearch-hooks-server';
About this function
getServerState()
is the function that retrieves the server state to pass to <InstantSearchSSRProvider>
.
This function is available from the companion react-instantsearch-hooks-server
package.
Examples
1
2
3
import { getServerState } from 'react-instantsearch-hooks-server';
const serverState = await getServerState(<App />);
Check the server-side rendering example for full markup.
Parameters
children
|
type: React.ReactNode
The part of the app that renders |
||
Copy
|
|||
renderToString
|
type: (node: React.ReactElement) => unknown
The react method used to render the app. This can be |
||
Copy
|
Returns
Promise
serverState
|
type: InstantSearchServerState
The server state to pass to |
||
Copy
|