rp-image-editor

React image editor

Add cropping, annotation and filters to your React app with one hook. The editor opens as an accessible full-screen modal and gives you back a File you can upload.

This is the real editor (v1.6.1). Pick a tool and try it.More demos, including multi-image →

Install

npm install @rageshpikalmunde/rp-image-editor @rageshpikalmunde/rp-image-editor-react

Usage

import { useRpImageEditor } from '@rageshpikalmunde/rp-image-editor-react';

export function AvatarUpload() {
  const { openEditor, openMultiEditor } = useRpImageEditor();

  async function onFile(e: React.ChangeEvent<HTMLInputElement>) {
    const file = e.target.files?.[0];
    if (!file) return;
    const result = await openEditor(file, { exportFormat: 'jpeg' });
    if (result) upload(result.file); // File, Blob and base64 are all returned
  }

  return <input type="file" accept="image/*" onChange={onFile} />;
}

Prefer it inline? Render <RpImageEditorComponent image={file} onImageEdited={save} /> instead of the modal. Works with Next.js (load it client-side), Vite, CRA and Ionic React.

What you get

Questions

Does it work with Next.js?

Yes. The editor uses the DOM and canvas, so load it on the client (for example inside useEffect or with next/dynamic and ssr: false).

Can users edit several images at once?

Yes: openMultiEditor(files) shows a thumbnail strip, keeps separate undo history per image and returns every image with an edited flag.

Is it typed?

Yes. The packages are written in TypeScript and ship their type definitions.

Try the full demo   npm · GitHub · API reference