
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeYou're correct that next-optimized-images primarily works with images from the filesystem through webpack imports. However, for working with Sanity's CDN, you don't actually need next-optimized-images at all - Sanity provides its own powerful image optimization solution that's better suited for remote images.
Sanity's Image Pipeline is an on-demand image transformation service that handles all the optimization you'd want from next-optimized-images (and more) directly through URL parameters. When you upload images to Sanity's Content Lake, they're automatically available through the global CDN at cdn.sanity.io with support for:
auto=formatFor Next.js specifically, the recommended approach is to use Sanity's image URLs with Next.js's built-in <Image> component. You can use the @sanity/image-url helper library to build optimized URLs programmatically:
import imageUrlBuilder from '@sanity/image-url'
import Image from 'next/image'
const builder = imageUrlBuilder(client)
function urlFor(source) {
return builder.image(source)
}
export default function MyComponent({ image }) {
return (
<Image
src={urlFor(image).width(800).url()}
alt={image.alt}
width={800}
height={600}
/>
)
}There's also a community package called next-sanity-image that provides even tighter integration between Sanity's Image Pipeline and Next.js's Image component, handling the props mapping automatically.
So to directly answer your question: yes, next-optimized-images is designed for filesystem imports, but you don't need it for Sanity images - Sanity's CDN already provides all the optimization features you need for remote images.
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store