useEditorImage
The useEditorImage hook from @react-email/editor/plugins creates the image
extension used for paste, drop, file-picker, and slash-command uploads.
image extension that:
- adds the
imagenode to the editor schema - handles image paste and drop events
- adds
editor.commands.uploadImage() - adds
editor.commands.setImage(...)
Configuration for the upload flow.
Types
UseEditorImageOptions
Called after a user pastes, drops, or selects an image file. Resolve with the
final hosted image URL.
UploadImageResult
The final image URL written back to the image node after upload completes.
imageSlashCommand
imageSlashCommand is a ready-made slash command item that triggers
editor.commands.uploadImage() after removing the typed slash-command range.
Layout.
Editor commands
RegisteringuseEditorImage() adds two commands to editor.commands.
uploadImage
Opens a native file picker with accept="image/*" and runs the configured
upload flow:
setImage
Inserts an image node directly:
Image source URL.
Alternate text for the image.
Rendered image width.
Rendered image height.
Alignment metadata used by the image UI and serializer.
Optional link URL. When present, the image is wrapped in a link on export.
Upload behavior
All upload entry points share the same behavior:- A temporary blob URL is inserted immediately so the image appears in the editor.
- Your
uploadImage(file)handler runs. - On success, the blob URL is replaced with the returned
url. - On failure, the temporary image node is removed and the error is logged.
EmailEditor integration
If you’re using EmailEditor, you can
enable the same behavior without calling useEditorImage() directly: