GrapesJS Tutorial — Getting Started Guide

From installation to custom blocks, plugins, and storage

Practical Tutorial

Build a production-ready GrapesJS editor in under an hour

This guide focuses on the workflow teams actually need: initialize fast, ship reusable blocks, persist project data, and avoid common implementation mistakes.

Setup time

5-10 min

Core steps

4 steps

Code examples

Ready to paste

Step 1: Installation and initialization

Install GrapesJS and render the editor in a container. Keep your first run intentionally minimal, then layer in custom modules.

  • 1. Add GrapesJS package and CSS import.
  • 2. Create a dedicated editor container.
  • 3. Disable storage until your backend endpoint is ready.
init.ts
import grapesjs from 'grapesjs';
import 'grapesjs/dist/css/grapes.min.css';

const editor = grapesjs.init({
  container: '#gjs',
  height: '100vh',
  width: 'auto',
  storageManager: false,
  plugins: [],
});

Step 2: Add user-friendly custom blocks

Blocks are the primary UX for non-technical editors. Use clear labels and keep categories aligned with how users think about page sections.

HeroFeaturesPricingTestimonialsFAQCTA
blocks.ts
editor.BlockManager.add('hero-section', {
  label: 'Hero Section',
  category: 'Sections',
  content: `
    <section style="padding: 80px 20px; text-align: center;">
      <h1>Your Headline Here</h1>
      <p>Add your subheadline and CTA below.</p>
      <a href="#" style="background: #4f46e5; color: white; padding: 12px 24px; border-radius: 6px; text-decoration: none;">
        Get Started
      </a>
    </section>
  `,
  attributes: { class: 'fa fa-columns' },
});

Step 3: Configure reliable storage

Move from browser-only data to remote storage once editing works locally. This unlocks collaborative and multi-device workflows.

  • 1. Use auth headers for protected routes.
  • 2. Version your saved project data format.
  • 3. Log save/load failures for faster debugging.
storage.ts
const editor = grapesjs.init({
  container: '#gjs',
  storageManager: {
    type: 'remote',
    storeComponents: true,
    storeStyles: true,
    storeHtml: true,
    storeCss: true,
    urlLoad: '/api/pages/load',
    urlStore: '/api/pages/save',
    headers: { Authorization: 'Bearer YOUR_TOKEN' },
  },
});

4-step learning roadmap

Step 01

Initialize the editor

Set up GrapesJS with a minimal config and make sure the canvas renders correctly inside your app shell.

Step 02

Define reusable blocks

Create a focused starter set: hero, features, pricing, CTA, and footer. Keep labels clear for non-technical users.

Step 03

Add project persistence

Save project JSON remotely so users can continue editing across sessions, browsers, and devices.

Step 04

Harden for production

Limit unsafe components, track editor events, and test export fidelity on mobile and desktop breakpoints.

Common mistakes to avoid

Saving only HTML/CSS

Use project data (JSON) when possible. It preserves editor structure and avoids losing component metadata.

No design tokens

Define typography, spacing, and color tokens early so teams build consistent pages faster.

Too many starter blocks

Start with a small, opinionated block set. Large block lists increase cognitive load and reduce adoption.

Ignoring events and analytics

Track block usage, publish actions, and failures. Event data helps prioritize the right product improvements.

Key GrapesJS concepts

Block Manager

Manages draggable blocks. Add blocks with BlockManager.add() or the blocks init option.

Component Manager

Manages component types. Define custom components with ComponentManager.addType().

Style Manager

Visual CSS editor panel. Configure sectors and properties to control what styles editors can change.

Storage Manager

Handles saving and loading editor content. Supports local, remote, and custom storage backends.

Canvas

The iframe editing area where components are dragged and dropped. Fully isolated from your app styles.

Plugin API

Plugins are functions that receive the editor instance and can modify any editor manager.

GrapesJS tutorial FAQ

Continue learning

Extend GrapesJS with production-ready plugins

Move faster with ready-made plugins for components, storage, forms, and advanced editor controls.

Browse plugins