Server Side Rendering for Places.js?

Hi - I’m working on building out the front-end instantsearch component for our app, and I’m running into issues with importing places.js given that we server side render our app. Specifically, getting this error at webpack build:

node_modules/autocomplete.js/zepto.js:5
}(/* this ##### UPDATED: here we want to use window/global instead of this which is the current file context ##### */ window, function(window) {
^

ReferenceError: window is not defined

Is there a workaround for this? I found great resources for vanilla instantsearch SSR (eg: https://community.algolia.com/react-instantsearch/guide/Server-side_rendering.html) , but I’m at a loss when trying to incorporate places.js. Any ideas/advice?

Thanks!

Hi @oliver, your best bet here would be NOT to use places.js which is a pure frontend component with no server-side rendering abilities today.

We might make more integration between place.js and React InstantSearch but for now it’s not doable.

Still, what you could do is to use the pure JavaScript client with the places data: https://community.algolia.com/places/documentation.html#javascript-api-client

Keep in mind that some of the places.js formatting will not be applied so you will have to read the data yourself.

I understand this is not ideal but SSR is a recent tech and we are not yet compatible at every layer with it.

Let us know how it goes.