DEV Community

Łukasz Wolnik
Łukasz Wolnik

Posted on

2 2

Cerebral Debugger in Next.js

If you are getting below error:

ReferenceError: WebSocket is not defined
    at Devtools.createSocket
Enter fullscreen mode Exit fullscreen mode

when trying to hook Cerebral Debugger up in Next.js try to refactor your bootstrap code from this:

const devTools =
  process.env.NODE_ENV === "production"
    ? null
    : {
        devtools: DevTools({
          host: "localhost:8585",
        }),
      };
Enter fullscreen mode Exit fullscreen mode

to this:

let devTools = null;

if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
  devTools = {
    devtools: DevTools({
      host: "localhost:8585",
    }),
  };
}
Enter fullscreen mode Exit fullscreen mode

Now you're be able to use Cerebral Debugger whilst still using Next.js when calling below:

export default App(({ app }) => {
  app.on("initialized", () => {
    app.getSequence("initialize")();
  });
  return {
    state,
    sequences,
    providers,
  };
}, devTools);
Enter fullscreen mode Exit fullscreen mode

SurveyJS custom survey software

JavaScript UI Libraries for Surveys and Forms

SurveyJS lets you build a JSON-based form management system that integrates with any backend, giving you full control over your data and no user limits. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs