-
I'm using InstantSearchSSRProvider. Every page has Autocomplete in the header, so I've wrapped the entire app is wrapped in I'm only generating server side state for list pages (powered by Algolia) as the data is not needed for non-list pages. However, this is causing non-list pages to be client side rendered. To reproduce the issue:
Is there a way to get SSR on non-list pages which only use Autocomplete? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hi @avremel , you need to pass down the data from <InstantSearchSSRProvider {...serverState}>
{/* ... */}
</InstantSearchSSRProvider> Edit: I missed the part when you specified you didn't want to retrieve // Determines whether or not to get the initial results from Algolia
const shouldGetServerState = false;
export const getServerSideProps: GetServerSideProps<HomePageProps> =
async function getServerSideProps({ req }) {
const protocol = req.headers.referer?.split('://')[0] || 'https';
const url = `${protocol}://${req.headers.host}${req.url}`;
const serverState = shouldGetServerState
? await getServerState(<HomePage url={url} />, {
renderToString,
})
: { initialResults: {} }
;
return {
props: {
serverState,
url,
},
};
}; |
Beta Was this translation helpful? Give feedback.
Hi @avremel , you need to pass down the data from
serverState
to<InstantSearchSSRProvider>
:Edit: I missed the part when you specified you didn't want to retrieve
initialResults
in non-list pages. For the moment this data is required, but you could replace it with an empty object in a similar manner as this: