Skip to content

Sirv for Contentful

By , Head of Sirv StudioUpdated

Open this page in a new chat

Short answer

In Contentful, go to Apps, find Sirv and click Install, then paste your Sirv REST API Client ID and Client secret and click Connect. Add a Sirv field to a content type, and editors can pick images, videos, 360 spins and Sirv Media Viewers from your Sirv account. Show them on your site with the @sirv/react components.

After reading this you will know

  • How to install Sirv in Contentful and connect your account
  • How to add a Sirv field to a content type
  • How to show the picked media on your website
Contentful logo

Add Sirv as a media source inside Contentful.

Connect your Sirv account, browse your Sirv DAM, and pick images, videos, 360 spins and Sirv Media Viewers without leaving the Contentful editor.

Your assets stay on Sirv and are delivered from Sirv’s global CDN, in the optimal image format (often WebP) at the perfect dimensions.

Typical file size is 40-70% smaller than the original, for faster pages, happier users and higher conversions.

Unlike copying files into Contentful’s media library, the Sirv app stores only a small JSON reference to each asset (its path, delivery domain and dimensions).

The file is never duplicated, so you keep Sirv’s dynamic imaging, responsive srcset, 360 spins and the Sirv Media Viewer on your live site.

The app is built on the Contentful App Framework and installs into any space. It ships zero credentials - you connect with your own Sirv REST API keys, once.

  1. In Contentful, open your space and go to Apps > Custom apps (or the Marketplace), find Sirv and click Install.
  2. Contentful opens the app’s configuration screen so you can connect your Sirv account (next section).
  3. After connecting, click Install to selected environments (top right) to finish. That’s it - the app is ready to add to your content types.

On the app’s configuration screen, paste your Sirv account’s REST API Client ID and Client secret, then click Connect.

Connect your Sirv account on the Contentful app configuration screen by pasting your REST API Client ID and secret

If your account has more than one delivery domain, you’ll be asked to choose which one to serve assets from.

Then click Save (or Install to selected environments on first install) at the top right of Contentful to store the connection.

Your credentials are saved as the app’s installation parameters and reused automatically afterwards - you only connect once.

In Sirv, go to Settings > API access. Copy the Client ID and Client secret shown there. Don’t have a Sirv account yet? Create a free account first.

Sirv assets live in dedicated fields on your content types. To add one:

  1. Open Content model, choose a content type and click Add field. Select JSON object (for a single asset or a gallery), or Short text (to store just an asset URL).

    Choosing the JSON object field type in Contentful's Add new field dialog
  2. Give the field a name, for example “Sirv Single Media”, and click Add and configure.

    Naming a new JSON object field Sirv Single Media in Contentful
  3. On the Appearance tab, select Sirv as the field editor. Then set Field type to the kind of content this field holds, and optionally restrict the Allowed asset types and the gallery render mode.

    Selecting Sirv as the field appearance and choosing Single media as the field type in Contentful
  4. Save the field and the content type. The Sirv picker now appears whenever you edit an entry of that type.

Choose a Field type in the appearance settings to control what a field stores:

  • Single media - one image, video, 360 spin or Sirv Media Viewer. Stored on a JSON object field.
  • Gallery - multiple assets, with multi-select and drag-to-reorder. Stored on a JSON object field.
  • Asset URL - any Sirv asset stored as a plain delivery URL string. Stored on a Short text field.

Use Allowed asset types to limit the picker to specific kinds, with a comma-separated list of image, video, spin, view and file. Leave it blank to allow all media types.

Open an entry that uses a Sirv field and click Add asset from Sirv.

The Add asset from Sirv button on a Sirv field in the Contentful entry editor

The Sirv media browser opens. Navigate your folders, search the whole account, and filter by type using the chips (Image, Video, 360 Spin, Sirv Media Viewer).

Browsing and filtering a Sirv account's folders and assets inside the Contentful media browser

Click an asset to preview it - images, videos, 360 spins and Sirv Media Viewers all preview live - then click Use this asset.

Previewing a selected Sirv image with its dimensions before confirming the choice

The asset is added to the field. For images and videos, the Alt text and Caption are auto-filled from the asset’s Sirv metadata, and you can fine-tune them (and image quality) inline.

A Sirv image added to a Contentful field showing its path, alt text, caption and quality controls

The field stores a small JSON value (or a URL string for the Asset URL field).

Render it on your frontend with the free @sirv/react package, which delivers responsive images, videos, 360 spins and combined Sirv Media Viewer galleries.

npm install @sirv/react

Pass the stored field value straight to the Sirv components:

import { SirvProvider, SirvMedia, SirvGallery, fromSanityMedia as fromSirvMedia } from '@sirv/react';
export function Product({ entry }) {
return (
<SirvProvider alias="youraccount.sirv.com" quality={82}>
{/* Single media field (image, video, 360 spin or viewer) */}
<SirvMedia value={fromSirvMedia(entry.fields.sirvSingleMedia)} width={640} />
{/* Gallery field, as one combined Sirv Media Viewer */}
<SirvGallery
items={entry.fields.gallery.map(fromSirvMedia)}
layout="viewer"
width={640}
height={480}
/>
</SirvProvider>
);
}

For an Asset URL field, the value is already a delivery URL - use it directly in an <img>, <a> or your own component.

Contentful’s Rich Text editor uses its own + Embed menu, which apps cannot add a custom source to. To place Sirv media inside rich text, use Contentful’s built-in embedded entry feature:

  1. Create a small content type, for example Sirv Media, with one JSON object field set to Appearance > Sirv, Field type Single media.

  2. In your Rich Text field, click + Embed > Entry (or Inline entry) and insert a Sirv Media entry, picking the asset with the usual Sirv browser.

    You can restrict the Rich Text field’s validations to only allow embedding the Sirv Media type for a clean, Sirv-only embed.

  3. When you render the rich text on your website, map the embedded-entry node to a Sirv component:

    import { documentToReactComponents } from '@contentful/rich-text-react-renderer';
    import { BLOCKS } from '@contentful/rich-text-types';
    import { SirvMedia, fromSanityMedia as fromSirvMedia } from '@sirv/react';
    const options = {
    renderNode: {
    [BLOCKS.EMBEDDED_ENTRY]: (node) => {
    const entry = node.data.target; // the resolved "Sirv Media" entry
    return entry?.fields?.media?.mediaType
    ? <SirvMedia value={fromSirvMedia(entry.fields.media)} width={640} />
    : null;
    },
    },
    };
    documentToReactComponents(richTextDocument, options);

Make sure your Delivery API query resolves the linked entries so the embedded entry’s fields are populated.

Sirv is more than an image CDN. Pick a 360 spin or a Sirv Media Viewer in the same browser, store it on a Sirv field, and render it with <SirvMedia> or <SirvGallery layout="viewer">.

The viewer combines images, videos and spins into one interactive gallery with zoomable images, on desktop and mobile.

Do my images get copied into Contentful?

No. The Sirv field stores only a small JSON reference (the asset's path, delivery domain and dimensions). The file stays on Sirv and is served from the Sirv CDN, so you keep dynamic imaging, responsive srcset, 360 spins and the Sirv Media Viewer.

Which Contentful field types can use Sirv?

A JSON object field (for a single asset or a gallery) and a Short text field (to store an asset URL). Set the field's Appearance to Sirv, then choose the Field type: Single media, Gallery, or Asset URL.

Does it support videos, 360 spins and the Sirv Media Viewer?

Yes. The media browser lets you pick images, videos, 360 spins and Sirv Media Viewers, with a live preview of each. They render on your website with the @sirv/react package.

Are my Sirv credentials safe?

You paste your own Sirv REST API Client ID and secret once, on the app's configuration screen. They are stored as the app's installation parameters and used only to talk to Sirv. The app bundles no credentials of its own.

Can I add Sirv to Contentful's native media field?

No. Contentful does not allow apps to add a source to its native Media reference field, and that field can only store links to Contentful assets. To keep assets on Sirv, use a JSON object field (Single media or Gallery) or a Short text field (Asset URL) instead.

Can I add Sirv media to a Rich Text field?

Yes, using Contentful's built-in embedded entries. Create a small content type with a Sirv field, then use + Embed > Entry in the Rich Text editor to insert it. Apps cannot add a custom item to the + Embed menu itself, so this embedded-entry approach is the supported way.

Back to top