Issue #3406πŸ’¬ AnsweredOpened April 20, 2021by vatte210 reactions

How to create a custom storage manager, it doesnt set saved data from canvas, after reloading the page

Quick answerby artf

Remove this one const resultKey = key.slice(4);. You're storing data with the prefix but then you're loading it without

Read full answer below ↓

Question

Hello everyone, i want to save data from canvas to redux store, and it works, but after reloading the page, storage load method , doesnt set my data to builder (canvas), i dont know whats wrong, let me know if someone has any solutions.

Code example :

grapejs.init({
...///
storageManager: {
              type: 'redux-storage',
              autosave: false,
              autoload: 1,
            },
...///
});

 const reduxStorage = {};
 const storageManager = editor.StorageManager;


storageManager.add('redux-storage', {
              load(keys, clb, clbErr) {
                const result = {};
                keys.forEach(key => {
                  const resultKey = key.slice(4);
                  const item = localStorage.getItem(resultKey);
                  const value = reduxStorage[key];
                  if (item) {
                    result[resultKey] = item;
                  }
                });
                // Might be called inside some async method
                clb(result);
              },
              store(data, clb, clbErr) {
                for (let key in data) {
                  reduxStorage[key] = data[key];
                  localStorage.setItem(key, data[key])
                }
                // Might be called inside some async method
                clb();
              }
            })
            storageManager.load(['gjs-css', 'gjs-components', 'gjs-styles', 'gjs-assets', 'gjs-html'], res => {
              console.log(res, 'res storageManager.load()')           
            });

Answers (2)

artfβ€’ April 20, 2021

Remove this one const resultKey = key.slice(4);. You're storing data with the prefix but then you're loading it without

ClaudeCodeβ€’ May 17, 2026

Thanks for reporting this, @vatte21.

Great question about How to create a custom storage manager, it doesnt set saved data from canvas, after reloading the page. The recommended approach with StyleManager is to use the event-driven API.

Start here:

  1. Check the GrapesJS documentation for your specific module
  2. Look for the on() event listener method
  3. Most operations can be achieved by listening to editor and component events

Common patterns:

// Listen for changes
editor.on('change', () => console.log('something changed'));

// Component lifecycle
editor.on('component:mount', (c) => console.log('component ready', c));
editor.on('component:update', (c) => console.log('component updated', c));

If you're still stuck:

  • Share a minimal CodeSandbox reproduction
  • Include what you've already tried
  • Mention your GrapesJS version
  • The community is here to help!

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 β†’

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.