---
title: "The Content SDK NextImage component"
slug: "the-content-sdk-nextimage-component"
abstract: "How to implement NextImage components in your Next.js Content SDK app."
---
# The Content SDK NextImage component

Next.js provides [`next/image`](https://nextjs.org/docs/app/api-reference/components/image), an optimized image rendering component that helps improve page load and rendering performance. To enable use of the `next/image` component in Content SDK applications, the `@sitecore-content-sdk/nextjs` package provides the `NextImage` component.

You can use the `NextImage` component instead of [the Content SDK `Image` component](https://doc.sitecore.com/sai/en/developers/content-sdk/20/the-content-sdk-image-component.html "The Content SDK Image component") to make use of the additional properties enabled by Next.js.

Similar to the `next/image` component, a properly configured `NextImage` component does the following:

- Serves correctly sized images for each device, using modern image formats.
- Improves the visual stability of the page.
- Improves page-loading time with lazy loading and visually attractive placeholders.
- Resizes images on demand, whether they are stored locally or remotely.

> [!note]
> The `NextImage` component uses the [Content SDK Media API](https://doc.sitecore.com/sai/en/developers/content-sdk/20/content-sdk-media-api.html "Content SDK Media API") to resize images.

## Configuring the NextImage component

The `NextImage` component uses built-in image optimization from Vercel, but you can provide your own [loader function](https://nextjs.org/docs/app/api-reference/components/image#loader) using the `loader` property if needed.

`NextImage` supports [the same properties as the `next/image` component](https://nextjs.org/docs/pages/api-reference/components/image) except `src`. It provides the following additional properties that you can use to further configure it:

<table style="width:100%;" class="informaltable frame-void rules-rows"><thead><tr><th class="th"><p>Name</p></th><th class="th"><p>Type</p></th><th class="th"><p>Description</p></th></tr></thead><tbody><tr><td class="td"><p><code class="code">field</code></p></td><td class="td"><p><code class="code">ImageField | ImageFieldValue</code></p></td><td class="td"><p>Required.</p><p>Image field data provided by a <code class="code">Placeholder</code> component.</p></td></tr><tr><td class="td"><p><code class="code">editable</code></p></td><td class="td"><p><code class="code">boolean</code></p></td><td class="td"><p>Whether the image can be edited in the SitecoreAI Page builder.</p><p>Default: <code class="code">true</code></p></td></tr><tr><td class="td"><p><code class="code">imageParams</code></p></td><td class="td"><p><code class="code">ImageSizeParameters[]</code></p></td><td class="td"><p>The <a class="link linktype-component" href="https://doc.sitecore.com/sai/en/developers/content-sdk/20/image-parameters-in-content-sdk-apps.html" title="Image parameters in Content SDK apps">query string parameters</a> to append to the image URL.</p></td></tr><tr><td class="td"><p><code class="code">mediaUrlPrefix</code></p></td><td class="td"><p><code class="code">RegExp</code></p></td><td class="td"><p>A regular expression that finds the media URL prefix to be replaced by <code class="code">/-/jssmedia</code> or <code class="code">/~/jssmedia</code>.r</p></td></tr></tbody></table>

> [!important]
> Attempting to use the `src` property will cause the `NextImage` component to generate an error. If you want to use this property to provide an image source URL, you will need to use the standard `next/image` component instead of Content SDK's `NextImage`.
>
> The `remotePatterns` setting present in the `next.config` file of the Content SDK sample app is set to a wildcard value. Do not use wildcard values in production. We recommend setting more specific hostnames for image optimization and better security before going live.

## Examples

The following examples describe how you can use the `NextImage` component to implement editable or non-editable responsive images.

### A simple, editable image

The following example renders a responsive image that is editable in the SitecoreAI Page builder:

```typescript
<NextImage field={props.fields.image} height="51" width="204" />
```

### A more advanced, non-editable image

The following example renders an image using server-side resize parameters. It's configured to not be editable in the Page builder:

```typescript
<NextImage field={props.fields.image} editable={false} unoptimized={true} imageParams={{ mw: 100, mh: 50 }} height="50" width="94" />
```

In this example:

- `editable` is `false`, meaning the image can't be edited in the Page builder.
- `unoptimized` disables `next/image` source optimization in favor of `imageParams`.
- `imageParams` passes parameters to SitecoreAI that resize the image on the server side.