Image optimization for Next.js 14, 15 and 16
Eliminate expensive Vercel image optimization overages. SmallPict serves as a high-performance custom loader for next/image, providing AVIF/WebP streaming, edge caching, and blurhash placeholders.
Install
$ npm install @smallpict/nextImplementation example
// smallpict-loader.ts
export default function smallPictLoader({ src, width, quality }: { src: string; width: number; quality?: number }) {
const params = new URLSearchParams({
url: src,
w: width.toString(),
q: (quality || 80).toString(),
f: 'auto'
});
return `https://cdn.smallpict.app/v1/optimize?${params.toString()}`;
}
// next.config.ts
import type { NextConfig } from 'next';
const nextConfig: NextConfig = {
images: {
loader: 'custom',
loaderFile: './smallpict-loader.ts',
},
};
export default nextConfig;Integration steps
Create smallpict-loader.ts
Configure the loader function to point at the SmallPict CDN.
Register in next.config.ts
Set images.loader = "custom" and images.loaderFile in your Next.js config.
Use standard next/image
Use Image as normal.
Key benefits
- Avoid $10/1000 requests Vercel image transform charges
- Edge-cached images worldwide
- Automatic responsive srcset generation
- Full Next.js App Router & Server Components support
Need complete implementation guides & API specs?
Explore parameter references, authentication mechanisms, error codes, and local testing instructions in our official Next.js Framework developer guide.
Read Next.js Framework DocsSpeed Up Your Next.js Framework Image Pipeline
Try AVIF and WebP image optimization in your application. No setup fee, and sandbox keys right away.