Reactotron doesn't work with NextJS because of SSR

570 views Asked by At

I'm configuring the redux store for my NextJS application and i usually use the Reactotron library to inspect the store. But, NextJS is server side rendering and if i import the configuration in the app file, it gives an error window is not defined

That's my config file: https://github.com/LauraBeatris/amazon-next/blob/develop/src/config/ReactotronConfig.js

And my app file: https://github.com/LauraBeatris/amazon-next/blob/develop/src/pages/_app.js

I want to know if there's a way of using Reactotron with NextJS

1

There are 1 answers

0
taubi19 On

In NextJS you can dynamically import a module on the client side only. You should import it like this:

import dynamic from "next/dynamic"

const DynamicComponentWithNoSSR = dynamic(
  () =>  import '~/config/ReactotronConfig',
  { ssr: false }
)

But I'm not sure if Reactotron will work the way you expect, as I don't know the library.