Render Sanity images with the Image component
Published: November 17, 2026
@sanity/sveltekit 3.1.0 adds <Image>, a Svelte 5 component in @sanity/sveltekit/image that takes the image field from your GROQ query and renders it from the Sanity Image CDN with a responsive srcset. The crop and hotspot editors set in the studio apply without a urlFor helper or hard-coded dimensions.
New features
Render image fields with <Image>
Pass an image object from a query as src. <Image> builds the CDN URL, applies the studio crop, and positions the crop around the hotspot when the aspect ratio you request differs. src accepts the shapes sanity typegen generates, stega-encoded values, asset documents and references, asset IDs, and CDN URLs. See Images in the @sanity/sveltekit README.
*[_type == "post" && slug.current == $slug][0]{
title,
mainImage{ crop, hotspot, asset->{ url, metadata { lqip } } }
}<script lang="ts">
import { Image, isImageWithAsset } from '@sanity/sveltekit/image';
let { data } = $props();
</script>
{#if isImageWithAsset(data.post.mainImage)}
<Image
src={data.post.mainImage}
alt={data.post.title}
width={800}
sizes="(min-width: 800px) 800px, 100vw"
placeholder="blur"
/>
{/if}<Image> reads the project ID and dataset from the asset URL when the query dereferences it (asset->{url}). If the query only selects the asset reference, pass projectId and dataset as props.
Leave out width and height
<Image> infers missing dimensions from the CDN URL, the crop, or the original dimensions in the asset filename. Set only one dimension and the other follows the image’s aspect ratio.
Blur placeholders from the image metadata
With placeholder="blur", <Image> uses the asset’s LQIP when the query includes asset->{url, metadata{lqip}}, so you don’t need blurDataURL. If the asset has no LQIP, no placeholder renders.
Art direction with getImageProps
getImageProps returns the same <img> attributes without rendering, so you can build a <picture> with a different crop per breakpoint. imageLoader builds a single CDN URL.
<script lang="ts">
import { getImageProps } from '@sanity/sveltekit/image';
let { image } = $props();
const common = { src: image, alt: '', sizes: '100vw' };
const desktop = $derived(getImageProps({ ...common, width: 1440, height: 640 }).props);
const mobile = $derived(getImageProps({ ...common, width: 750, height: 1000 }).props);
</script>
<picture>
<source media="(min-width: 1000px)" srcset={desktop.srcset} />
<img {...mobile} />
</picture>Improvements
fill: stretches the image over its positioned parent, withobject-positiondefaulting to the hotspot.queryParams: a new prop that adds image transformation parameters to the URL, for examplequeryParams={{ sat: -100 }}.preload: adds a<link rel="preload">to the document head for images above the fold.- TypeGen:
InferImageValue,InferStrictImageValue, andisImageWithAssetare re-exported from@sanity/sveltekit/image, and theInfer*types accept stega-encoded query results. - Dependencies:
@sanity/visual-editingis updated to v6, which requires Node.js 22.12 or later. If you build on Node.js 20, upgrade Node.js when you upgrade@sanity/sveltekit.
For the full list of changes, see the @sanity/sveltekit 3.1.0 release on GitHub.