Skip to main content

Next.js VideoEditor Integration Guide

Complete guide for integrating the @layermetry/media-editor VideoEditor component into your Next.js application.
This page still describes the version 1 setup. In version 2 (@layermetry/media-editor 2.0.0) ffmpeg was removed, so the 31 MB of WebAssembly named below no longer ships with the package and there is nothing to copy into public/. React is no longer pinned to 18.2.0 either — React 18 and React 19 both work, and the editor also runs with no React at all.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 (not 15.x - see React version requirements)
  • React 18 or React 19 — both work. Version 2 does not pin React, and also runs with no React at all.
  • ~40MB of disk space for WASM modules

Installation

1. Install the SDK

2. Install Required Dependencies

3. Configure Next.js for React 18

package.json:

WASM Files Setup

CRITICAL: VideoEditor requires WebAssembly modules for video processing. These must be copied to your public/ folder.

Step 1: Copy WASM Files

Run this command from your Next.js project root:

Step 2: Verify Files

Your public/ folder should contain:

Step 3: Configure URL Rewrites

If your editor pages are nested (e.g., /studio/video), add rewrites to next.config.js: next.config.js:

VideoEditor Interface

Core Props

Callback Types


Step-by-Step Integration

Step 1: Create Your Page Component

app/studio/video/page.tsx:

Step 2: Implement File Selection

Step 3: Implement Export Callback

Step 4: Render the Editor


Theme Customization

Creating a Custom Theme

Applying the Theme


Video Processing

Understanding Video Export

The VideoEditor uses FFmpeg (WebAssembly) for video processing:
  1. Decoding: Video frames are decoded using decode_worker.js
  2. Canvas Rendering: Frames are rendered with effects/overlays on Konva canvas
  3. Encoding: Frames are re-encoded to H.264/MP4 using encode_worker.js
  4. Output: Final video is returned as Blob/Object URL

Export Options

Performance Considerations

  • Video Size: Larger videos take longer to process (1-2 minutes for 1080p 30s video)
  • Browser Memory: Processing requires significant memory (500MB+ for HD video)
  • Mobile Support: May not work well on mobile devices due to memory constraints
  • Progress Indication: Always show loading indicator during export

Complete Example

app/studio/video/page.tsx:

Troubleshooting

WASM Files Not Loading

Symptom: “MediaInfoModule.wasm 404 Not Found” Solution:
  1. Verify WASM files are in public/ folder
  2. Check URL rewrites in next.config.js
  3. Restart dev server after config changes

Video Not Exporting

Symptom: Export hangs or fails Possible causes:
  • Browser out of memory (try smaller video)
  • FFmpeg workers not loaded (check console for errors)
  • Video codec not supported (try H.264/MP4)

Timeline Not Showing

Symptom: Timeline is blank or missing Solution:
  • Ensure SDK CSS is imported in globals.css
  • Check browser console for errors
  • Verify video file is valid

Next Steps

  1. See FAQ for common issues and solutions
  2. See Next.js ImageEditor Integration for image editing
  3. Check the included example project for a complete working implementation

Support

For issues or questions: