/nextjs-16:configuring-image-optimizationfrom nextjs-16
Teach image optimization configuration changes in Next.js 16. Use when configuring images, troubleshooting image loading, or migrating image settings.
Ships in nextjs-16. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
domains (removed)
remotePatternsloader (removed for 'default')
formats array changes
minimumCacheTTL
deviceSizes
[640, 750, 828, 1080, 1200, 1920, 2048, 3840][640, 750, 828, 1080, 1200, 1920, 2048, 3840, 4096]imageSizes
[16, 32, 48, 64, 96, 128, 256, 384][16, 32, 48, 64, 96, 128, 256, 384, 512]dangerouslyAllowSVG
contentDispositionType settingunoptimized
module.exports = {
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'example.com',
port: '',
pathname: '/images/**',
},
],
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
formats: ['image/webp', 'image/avif'],
minimumCacheTTL: 31536000,
},
}
Securely allow external image sources:
module.exports = {
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'cdn.example.com',
pathname: '/media/**',
},
{
protocol: 'https',
hostname: '*.cloudinary.com',
pathname: '/**',
},
],
},
}
Pattern properties:
protocol: 'http' or 'https'hostname: exact match or wildcard (*.example.com)port: specific port number (optional)pathname: glob patterns using ** for nested pathsControls optimized image cache duration:
module.exports = {
images: {
minimumCacheTTL: 60,
},
}
Common values:
60: Frequently changing images3600: Hourly updates (1 hour)86400: Daily updates (1 day)31536000: Static assets (1 year, default)Sizes for images with explicit sizes prop:
module.exports = {
images: {
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
},
}
Usage:
<Image
src="/avatar.jpg"
sizes="(max-width: 768px) 64px, 128px"
width={128}
height={128}
alt="Avatar"
/>
Viewport breakpoints for responsive images:
module.exports = {
images: {
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
},
}
Usage:
<Image
src="/hero.jpg"
fill
sizes="100vw"
alt="Hero"
/>
Control local file optimization access:
module.exports = {
images: {
localPatterns: [
{
pathname: '/public/uploads/**',
search: '',
},
],
},
}
Before:
module.exports = {
images: {
domains: ['example.com', 'cdn.example.com'],
},
}
After:
module.exports = {
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'example.com',
pathname: '/**',
},
{
protocol: 'https',
hostname: 'cdn.example.com',
pathname: '/**',
},
],
},
}
Before (60s default):
module.exports = {
images: {
domains: ['api.example.com'],
},
}
After (explicit cache):
module.exports = {
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'api.example.com',
pathname: '/dynamic-images/**',
},
],
minimumCacheTTL: 300,
},
}
Before:
module.exports = {
images: {
domains: ['*.cloudinary.com'],
},
}
After:
module.exports = {
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'res.cloudinary.com',
pathname: '/my-account/image/upload/**',
},
],
},
}
module.exports = {
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'cdn.production.com',
pathname: '/**',
},
],
formats: ['image/avif', 'image/webp'],
minimumCacheTTL: 31536000,
dangerouslyAllowSVG: false,
},
}
module.exports = {
images: {
remotePatterns: [
{
protocol: 'http',
hostname: 'localhost',
port: '3001',
pathname: '/**',
},
],
minimumCacheTTL: 60,
},
}
const isProd = process.env.NODE_ENV === 'production'
module.exports = {
images: {
remotePatterns: isProd
? [
{
protocol: 'https',
hostname: 'cdn.production.com',
pathname: '/**',
},
]
: [
{
protocol: 'http',
hostname: 'localhost',
port: '3001',
pathname: '/**',
},
],
minimumCacheTTL: isProd ? 31536000 : 60,
},
}
module.exports = {
images: {
deviceSizes: [375, 414, 640, 750, 828, 1080],
imageSizes: [24, 32, 48, 64, 96],
},
}
module.exports = {
images: {
dangerouslyAllowSVG: true,
contentDispositionType: 'inline',
contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;",
},
}
Check pattern matches URL:
remotePatterns: [
{
protocol: 'https',
hostname: 'example.com',
pathname: '/images/**',
},
]
Verify:
Override default TTL:
module.exports = {
images: {
minimumCacheTTL: 3600,
},
}
Clear build cache:
rm -rf .next
npm run build
Enable with security:
module.exports = {
images: {
dangerouslyAllowSVG: true,
contentDispositionType: 'inline',
contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;",
},
}
Reduce size variants:
module.exports = {
images: {
deviceSizes: [640, 828, 1200, 1920],
imageSizes: [32, 64, 128, 256],
},
}
For comprehensive examples and advanced configurations, see the references/ directory:
configuration-examples.md
security-settings.md
troubleshooting.md
migration-guide.md
images-component skill for Next.js Image component usageimages-responsive skill for responsive image patternsimages-loaders skill for custom image loader configurationWhat SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub djankies/claude-configs --plugin nextjs-169 skills in this plugin
/implementing-parallel-routesTeach parallel routes and slot patterns in Next.js 16. Use when implementing parallel routes, working with @slot syntax, or encountering missing default.tsx errors./migrating-async-request-apisTeach async request APIs in Next.js 16 - params, searchParams, cookies(), headers(), draftMode() are now async. Use when migrating from Next.js 15, fixing type errors, or working with request data./migrating-middleware-to-proxyTeach middleware.ts to proxy.ts migration in Next.js 16. Use when migrating middleware, encountering middleware errors, or implementing request proxying./reviewing-nextjs-16-patternsReview code for Next.js 16 compliance - security patterns, caching, breaking changes. Use when reviewing Next.js code, preparing for migration, or auditing for violations./securing-data-access-layerTeach Data Access Layer pattern to prevent CVE-2025-29927 middleware authentication bypass. Use when implementing authentication, authorization, protecting routes, or working with server actions that need auth./securing-server-actionsTeach server action authentication and security patterns in Next.js 16. Use when implementing server actions, form handlers, or mutations that need authentication.