Search Docs
Loading...
Skip to content

AI Editor for React

Quickly add AI-powered visual editing and media generation to your web app — seamlessly connect any AI model.

Design Editor starter kit showing a professional design editing interface

10 mins
estimated time
Download
StackBlitz
GitHub

Prerequisites#

Before you begin, make sure you have the following:

  • Node.js v22+ and npm installed locally – Download Node.js
  • IMG.LY API key – Create one in the IMG.LY dashboard for the AI Gateway
  • A supported browser – Chrome 114+, Edge 114+, Firefox 115+, Safari 15.6+
    See Browser Support for the full list.

Get Started#

Start fresh with a standalone AI Editor project. This creates a complete, ready-to-run React application with Design, Photo, and Video editing modes and AI generation capabilities.

Step 1: Clone the Repository#

Terminal
git clone https://github.com/imgly/starterkit-ai-editor-react-web.git
git clone https://github.com/imgly/starterkit-ai-editor-react-web.git

The src/ folder contains the editor code:

src/
├── app/ # Demo application
├── imgly/
│ ├── index.ts # Editor initialization function
│ ├── demo-assets.ts # Demo asset URLs
│ ├── config/
│ │ ├── design-editor/
│ │ │ ├── plugin.ts # Main configuration plugin
│ │ │ ├── actions.ts # Export/import actions
│ │ │ ├── features.ts # Feature toggles
│ │ │ ├── i18n.ts # Translations
│ │ │ ├── settings.ts # Engine settings
│ │ │ ├── keyboard/ # Keyboard shortcuts
│ │ │ │ ├── keyboard.ts # Shortcut registration
│ │ │ │ └── catalogs/
│ │ │ │ └── us-ansi.ts # Key catalog
│ │ │ └── ui/ # UI customization
│ │ │ ├── index.ts # Combines UI customization exports
│ │ │ ├── canvas.ts # Canvas configuration
│ │ │ ├── components.ts # Custom component registration
│ │ │ ├── dock.ts # Dock layout configuration
│ │ │ ├── inspectorBar.ts # Inspector bar layout
│ │ │ ├── navigationBar.ts # Navigation bar layout
│ │ │ ├── panel.ts # Panel configuration
│ │ │ └── videoTimeline.ts # Timeline configuration
│ │ ├── photo-editor/ # Same structure as design-editor/
│ │ └── video-editor/ # Same structure as design-editor/
│ └── plugins/
│ ├── ai-apps.ts # AI apps plugin setup
│ ├── ai-photo-edit.ts # AI photo editing
│ └── ai-providers.ts # AI provider setup
└── index.tsx # Application entry point

Step 2: Install Dependencies#

Install the required packages:

Terminal
cd starterkit-ai-editor-react-web
npm install
cd starterkit-ai-editor-react-web
npm install

Step 3: Download Assets#

CE.SDK requires engine assets (fonts, icons, UI elements) to function. For production, serve them as static files from your project’s public/ directory.

Terminal
curl -O https://cdn.img.ly/packages/imgly/cesdk-js/1.87.0-rc.3/imgly-assets.zip
unzip imgly-assets.zip -d public/
rm imgly-assets.zip
curl -O https://cdn.img.ly/packages/imgly/cesdk-js/1.87.0-rc.3/imgly-assets.zip
unzip imgly-assets.zip -d public/
rm imgly-assets.zip

Without further setup, the editor loads these assets from the IMG.LY CDN, which is for development only. To use the downloaded copy, set baseURL: '/assets' in the editor configuration in src/index.tsx. To add your license key, add one of the two license lines below to the same object, without the leading //. Option 1 puts the key in the code. Option 2 reads VITE_CESDK_LICENSE from a .env file, which you create as a copy of .env.example. Without a license key, the editor runs in evaluation mode and adds a watermark to exports.

src/index.tsx
const editorConfig = {
// ...
baseURL: '/assets',
// license: 'YOUR_CESDK_LICENSE_KEY' // Option 1: the key in the code
// license: import.meta.env.VITE_CESDK_LICENSE // Option 2: the key from .env
// ...
};

Step 4: Run the Development Server#

Without an IMG.LY API key, the starter kit shows a setup screen instead of the editor. Add the key first, as Configure the AI Gateway describes.

Terminal
npm run dev
npm run dev

Open http://localhost:5173 in your browser. Use the mode selector at the top to switch between Design, Photo, and Video modes.

Configure the AI Gateway#

The AI Editor sends every AI request through the IMG.LY AI Gateway, so it needs one IMG.LY API key. Create a key in the IMG.LY dashboard.

In the cloned starter kit, return the key from getApiKey() in src/app/ai-credentials/ai-credentials.ts:

src/app/ai-credentials/ai-credentials.ts
const key: string | undefined = 'YOUR_IMGLY_API_KEY';

In a production build, you can also paste the key into the setup screen that the editor shows when it has no key.

Set Up a Scene#

Replace the scene.create line from Get Started with one of these calls.

In the cloned starter kit, cesdk is available in the init callback in src/app/App.tsx.

CE.SDK offers multiple ways to load content into the editor. Choose the method that matches your use case:

src/components/DesignEditor.tsx
// Create a blank design canvas - starts with an empty design scene
await cesdk.actions.run('scene.create');
// Load from a template archive - restores a previously saved project
await cesdk.load('https://example.com/template.zip');
// Load from an image URL - creates a new scene with the image
await cesdk.createFromImage('https://example.com/image.jpg');
// Load from a scene file - restores a saved scene
await cesdk.load('https://example.com/scene.scene');

Customize Assets#

The AI Editor uses asset source plugins to provide built-in libraries for templates, stickers, shapes, and fonts. The starter kit includes a curated selection—customize what’s included based on your needs.

Asset sources are added via plugins. Enable or disable individual sources:

src/imgly/config/design-editor/plugin.ts
import {
FiltersAssetSource,
StickerAssetSource,
TextAssetSource,
VectorShapeAssetSource,
EffectsAssetSource,
// ...
} from '@cesdk/cesdk-js/plugins';
// Add only the sources you need
await cesdk.addPlugin(new FiltersAssetSource());
await cesdk.addPlugin(new StickerAssetSource());
await cesdk.addPlugin(new TextAssetSource());
await cesdk.addPlugin(new VectorShapeAssetSource());
await cesdk.addPlugin(new EffectsAssetSource());
// ...

For production deployments, self-hosting assets is required—the IMG.LY CDN is intended for development only. See Serve Assets for downloading assets, configuring baseURL, and excluding unused sources to optimize load times.

Configure Actions#

Actions are functions that handle user interactions like exporting designs, saving scenes, and importing files. CE.SDK provides built-in actions that you can run directly or override with custom implementations.

Key built-in actions:

  • exportDesign – Export the current design to PNG, JPEG, PDF, or other formats
  • saveScene – Save the scene as a JSON string for later editing
  • importScene – Import a previously saved scene (.imgly or .scene)
  • exportScene – Export the scene as an .imgly file, either the scene alone or an archive with all assets
  • uploadFile – Handle file uploads with progress tracking

In the cloned starter kit, cesdk is available in the init callback in src/app/App.tsx.

Use cesdk.actions.run() to execute any action:

src/components/DesignEditor.tsx
// Run a built-in action
await cesdk.actions.run('exportDesign', { mimeType: 'image/png' });

Import from File Picker#

src/imgly/config/design-editor/actions.ts
// Let users open images from their device
cesdk.actions.register('importImage', async () => {
const blobURL = await cesdk.utils.loadFile({
accept: 'image/*',
returnType: 'objectURL'
});
await cesdk.createFromImage(blobURL);
});

Export and Save#

src/imgly/config/design-editor/actions.ts
// Register export action that downloads the edited design
cesdk.actions.register('exportDesign', async (exportOptions) => {
const { blobs, options } = await cesdk.utils.export(exportOptions);
await cesdk.utils.downloadFile(blobs[0], options.mimeType);
});

Customize (Optional)#

Theming#

CE.SDK supports light and dark themes out of the box, plus automatic system preference detection. Switch between themes programmatically:

src/imgly/index.ts
// 'light' | 'dark' | 'system' | (() => 'light' | 'dark')
cesdk.ui.setTheme('dark');

See Theming for custom color schemes, CSS variables, and advanced styling options.

Localization#

Customize UI labels and add support for multiple languages. The i18n system supports translation keys for all UI elements:

src/imgly/config/design-editor/i18n.ts
// Override specific labels
cesdk.i18n.setTranslations({
en: {
'component.fileOperation.exportImage': 'Download Design',
'libraries.ly.img.image.label': 'Photos',
'common.done': 'Finish'
}
});
// Set the active locale
cesdk.i18n.setLocale('de');

See Localization for supported languages, translation key reference, and right-to-left language support.

UI Layout#

CE.SDK Editor UI Areas

Customize the editor interface by modifying the dock, inspector bar, navigation bar, and canvas menu. CE.SDK provides Order APIs to control which components appear and in what sequence.

See Dock, Inspector Bar, Navigation Bar, Canvas Menu, and Canvas for detailed layout customization options.

Settings & Features#

Fine-tune editor behavior through settings and features.

Settings configure core engine behavior—rendering, input handling, and page display:

src/imgly/config/design-editor/settings.ts
engine.editor.setSetting('page/dimOutOfPageAreas', true);
engine.editor.setSetting('mouse/enableZoom', true);
engine.editor.setSetting('doubleClickToCropEnabled', true);

Features toggle which editing tools and panels appear in the UI:

src/imgly/config/design-editor/features.ts
// Switch editor features on
cesdk.features.configure({
'ly.img.crop': { enabled: true },
'ly.img.filter': { enabled: true },
'ly.img.adjustment': { enabled: true }
});

See Settings and Features for the complete reference.

Explore Plugins#

CE.SDK has a rich plugin ecosystem that extends the editor with powerful capabilities.

AI Generation#

The AI Editor uses multiple plugins for different generation capabilities:

  • @imgly/plugin-ai-apps-web - Main AI Apps interface
  • @imgly/plugin-ai-generation-web - Core generation utilities
  • @imgly/plugin-ai-image-generation-web - Image generation (fal.ai, OpenAI)
  • @imgly/plugin-ai-text-generation-web - Text generation (Anthropic, OpenAI)
  • @imgly/plugin-ai-video-generation-web - Video generation (fal.ai)
  • @imgly/plugin-ai-audio-generation-web - Audio generation (ElevenLabs)
src/imgly/plugins/ai-apps.ts
import AiApps from '@imgly/plugin-ai-apps-web';
import FalAiImage from '@imgly/plugin-ai-image-generation-web/fal-ai';
import Anthropic from '@imgly/plugin-ai-text-generation-web/anthropic';
import FalAiVideo from '@imgly/plugin-ai-video-generation-web/fal-ai';
import Elevenlabs from '@imgly/plugin-ai-audio-generation-web/elevenlabs';
await cesdk.addPlugin(
AiApps({
providers: {
text2image: FalAiImage({ proxyUrl: '...' }),
text2text: Anthropic({ proxyUrl: '...' }),
text2video: FalAiVideo({ proxyUrl: '...' }),
text2audio: Elevenlabs({ proxyUrl: '...' })
}
})
);

See AI Integration for provider setup and supported AI features.

Background Removal#

Add AI-powered background removal that runs entirely client-side:

src/imgly/index.ts
import BackgroundRemovalPlugin from '@imgly/plugin-background-removal-web';
await cesdk.addPlugin(BackgroundRemovalPlugin());

See Background Removal for setup instructions and configuration options.


Key Capabilities#

The AI Editor includes everything needed for AI-powered creative editing.

Image Generation

Image Generation

Generate images from text prompts or transform existing images with AI-powered styles and effects.

Video Generation

Video Generation

Create short video clips from images or prompts with AI-powered animation and effects.

Audio Generation

Audio Generation

Generate royalty-free soundtracks and audio effects from text descriptions.

Voice Generation

Voice Generation

Create natural-sounding voiceovers from text scripts with adjustable speed and voice selection.

Background Removal

Background Removal

AI-powered background removal that runs entirely in the browser without server dependencies.

Multi-Mode Editing

Multi-Mode Editing

Switch between Design, Photo, and Video editing modes with optimized configurations for each.



Troubleshooting#

Editor doesn’t load#

  • Check the editor size: Ensure the width and height of <CreativeEditor> give it a visible area
  • Verify the baseURL: Assets must be accessible from the CDN or your self-hosted location
  • Check console errors: Look for CORS or network errors in browser developer tools

AI generation fails#

  • Check your API key: Make sure getApiKey() returns a valid IMG.LY API key that has not expired
  • Check network requests: Open DevTools Network tab and look for failed requests to gateway.img.ly

Assets don’t appear#

  • Check network requests: Open DevTools Network tab and look for failed requests to cdn.img.ly
  • Self-host assets for production: See Serve Assets to host assets on your infrastructure

Watermark appears in production#


Next Steps#

  • AI Integration – Configure AI providers and proxy servers
  • Configuration – Complete list of initialization options
  • Serve Assets – Self-host engine assets for production
  • Actions – Build custom export and save workflows
  • Theming – Customize colors and appearance