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:

}(/* 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: , but I’m at a loss when trying to incorporate places.js. Any ideas/advice?


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:

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.