getServerState()
This is the React InstantSearch v7 documentation. React InstantSearch v7 is the latest version of React InstantSearch and the stable version of React InstantSearch Hooks.
If you were using React InstantSearch v6, you can upgrade to v7.
If you were using React InstantSearch Hooks, you can still use the React InstantSearch v7 documentation, but you should check the upgrade guide for necessary changes.
If you want to keep using React InstantSearch v6, you can find the archived documentation.
const serverState = await getServerState(children: ReactNode, { renderToString?: (node: ReactElement) => unknown, })
1
import { getServerState } from 'react-instantsearch';
About this function
If you’re looking for Next.js App Router support, a dedicated react-instantsearch-nextjs
experimental package is available. Check the documentation for its usage.
getServerState()
is the function that retrieves the server state to pass to <InstantSearchSSRProvider>
.
Examples
1
2
3
import { getServerState } from 'react-instantsearch';
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
|