question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hello.

This module doesn’t support server side rendering. When building on Netlify or on local production, I get an error that says “‘window’ is not available during server side rendering”, and a bunch of code that is returned from the EditorJS plugin(s).

This is how I currently fixed this:


const MyComponent = () => {
  if (typeof window !== 'undefined') {
    const Editor = require('./editor').default;

    return <Editor />;
  }

  return null;
};

Even though this works, it’s very ‘hacky’. Please fix this.

I’m using GatsbyJS version 2.23.12.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:20 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
thealpha93commented, May 14, 2021

Using the require statement in the useEffect hook solved this issue for me in Nextjs. Thanks

import {useEffect} from 'react'


export default function editor() {
    useEffect(() => {
        const Editorjs = require('@editorjs/editorjs')
        new Editorjs('editorjs')
    }, [])


    return(
        <div id='editorjs'></div>
    )
}
6reactions
HaNdTriXcommented, Feb 10, 2021

This should work:

const EditorJs = dynamic(() => import("react-editor-js"), {
  ssr: false,
  loading: () => <p>loading editor.js ...</p>,
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Server-Side Rendering - Vite
Vite provides built-in support for server-side rendering (SSR). The Vite playground contains example SSR setups for Vue 3 and React, which can be...
Read more >
Server-Side Rendering (SSR) - Vue.js
Support Vue SFCs and other build step requirements. In fact, we will need to coordinate two builds for the same app: one for...
Read more >
Server Side Rendering - SAFE Documentation
Server-Side Rendering (SSR) means that some parts of your application code ... Better SEO support, as web crawlers will directly see the fully...
Read more >
SSR Support for AWS Amplify JavaScript Libraries
Enabling Server-Side Rendering (SSR) support in an Amplify app. When using the Amplify CLI, the aws-exports.js file gets created and updated ...
Read more >
What is Server-Side Rendering (SSR)? What Frameworks ...
What Frameworks Support SSR for Web Development? Delivering vital information and content to the browser is necessary for frontends to load quickly.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found