Skip to main content

Next.js ImageEditor Integration Guide

Complete guide for integrating the @layermetry/media-editor ImageEditor component into your Next.js application.
This page still describes the version 1 setup. In version 2 (@layermetry/media-editor 2.0.0) React is no longer pinned to 18.2.0 — React 18 and React 19 both work, and the editor also runs with no React at all, so Next.js 15 is fine.Follow Installation for the version 2 setup. This page is being rewritten.

Table of Contents


Prerequisites

  • Node.js 18 or newer
  • Next.js 14.x or 15.x
  • React 18 or React 19 — both work. Version 2 does not pin React, and also runs with no React at all.

Installation

1. Install the SDK

2. Install Required Dependencies

3. Configure Next.js for React 18

If you’re using Next.js 15+ (which requires React 19), you need to downgrade to Next.js 14: package.json:

Basic Setup

1. Import SDK Styles

Add the SDK CSS to your global styles file: app/globals.css:

2. Configure Next.js

next.config.js:

3. Use Dynamic Import (Avoid SSR)

The SDK uses browser-only APIs, so you must use dynamic imports:

ImageEditor Interface

Core Props

Callback Types


Step-by-Step Integration

Step 1: Create Your Page Component

app/studio/image/page.tsx:

Step 2: Implement File Selection

Step 3: Implement Callbacks

Step 4: Render the Editor


Theme Customization

Creating a Custom Theme

Applying the Theme


Callbacks and Event Handling

Export Callback

Called when user exports the edited image:

Close Callback

Called when user clicks close/cancel:

Template Callbacks

Save and load custom templates:

Complete Example

app/studio/image/page.tsx:

Next Steps

  1. See FAQ for common issues and troubleshooting
  2. See Next.js VideoEditor Integration for video editing
  3. Check the included example project for a complete working implementation

Support

For issues or questions, please visit: