Discussions

Ask a Question
Back to All

Gymnast with nextjs

How can I use GymnastProvider with next js without doing SSR false

Admin

I don't have experience with next js, but if it's causing issues I'm guessing we'll need to make some changes to make it work on the server. What's the error you are seeing?

To make gymnast isomorphic we would need to add checks anywhere we are using window and provide some default handling when we are rendering server side.

The most apparent issue here I think is how to handle responsive breakpoint layout config. The use of window.matchMedia is problematic in SSR. I think a common solution with other css-in-js solutions is to default to a desktop rendering then swap to mobile when client-side rendering kicks in.

I don't recall if there are some weird considerations here like react/next complaining that there's a mismatch between what the server rendered and what the client rendered.

So, requires some investigation but that's where I'd start.