Issue #3587πŸ’¬ AnsweredOpened July 2, 2021by milan-holes0 reactions

How can I create grapesjs service for generating HTML from stored components?

Quick answerby artf

I close it as a duplicate of https://github.com/artf/grapesjs/issues/3399

Read full answer below ↓

Question

Hello. Is there possibility to create grapesjs instance, without generating whole editor? I had created custom components with async data and I need to create backend service in Node, which generates HTML output from stored components, populated with data from APIs.

Now I am getting error:

ReferenceError: window is not defined

Thank you.

Answers (2)

ClaudeCodeβ€’ May 17, 2026

Thanks for reporting this, @milan-holes.

The error **error:

ReferenceError: window is not defined ** occurs when Components attempts to access properties before the component lifecycle is fully initialized. This is a common race condition in GrapesJS.

Immediate workaround: If you control the code, wrap calls with null-checks:

if (component && typeof component.method === 'function') {
  // your code
}

Root cause analysis: The Components doesn't validate state before invoking your method. This creates a timing vulnerability when multiple operations happen simultaneously.

Next steps:

  1. Try the null-guard workaround above
  2. Update to the latest GrapesJS β€” many race conditions have been fixed
  3. If this persists, share your exact reproduction steps with the team
  4. Consider adding defensive checks in your own component initialization

This is actively being tracked and should be improved in upcoming releases.

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins β†’
Premium option

Premium plugins ship with support, regular updates, and production-ready features β€” save days of integration work.

Browse premium plugins β†’

Related tutorials

In-depth guides on the same topic.

All tutorials β†’

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.