strapi-component-preview
v1.0.4
Published
Strapi 5 plugin that adds a preview-url custom field (with native media library picker) and an edit-view side panel showing component screenshots. Content editors pick a screenshot from the media library, its URL is stored on the component instance, and t
Maintainers
Readme
strapi-component-preview
A Strapi 5 plugin that adds a preview screenshot field to any component and shows all component previews as a side panel in the edit view.
Content editors pick a screenshot from Strapi's native Media Library, its URL is stored on the component instance, and the panel displays it live — reordering components reorders the panel, and duplicate components collapse into a count badge.
Install
npm install strapi-component-preview
# or
yarn add strapi-component-preview
# or
bun add strapi-component-previewStrapi auto-discovers the plugin — no config/plugins.ts entry required (unless you want to disable it or pass options later).
Rebuild the admin:
npm run buildAdd the preview field to your components
You have two options:
Option 1 — Auto-add to all components (recommended)
Run the bundled CLI from the root of your Strapi project:
npx strapi-component-previewThis walks src/components/**/*.json and adds a preview custom field to every component schema (idempotent — safe to re-run).
Option 2 — Manual
In Strapi's Content-Type Builder, edit each component → Add another field → Custom → pick "Preview Screenshot URL". Name the field exactly preview.
Usage
- In Strapi Media Library, upload your component screenshots (they can live on any CDN your upload provider supports — local disk, S3, Shopify CDN, Cloudinary, etc.).
- Open an entry that uses your components and expand a component.
- The
previewfield shows a URL input + Browse button. - Click Browse → Strapi's native media library opens → pick the screenshot → the URL fills in and the image displays inline.
- The Component previews side panel on the right shows all component screenshots for the current entry.
Behavior
- Dynamic zone: panel items appear in the current order. Reorder components → panel reorders live.
- Duplicate components in a dynamic zone: single card with
• N instancesbadge. - Regular component fields: deduplicated and sorted alphabetically.
- Fallback: if a component schema has
info.preview(a URL) set, it's used as a default when no entry-level value is provided.
What the plugin registers
- Custom field type:
plugin::component-preview.preview-url(stored asstring) - Custom field UI: URL text input + Media Library browser + inline thumbnail with Change / Clear
- Content-Manager edit-view side panel: "Component previews"
Supported Strapi versions
Strapi 5.x
License
MIT
