Skip to content

Conversation

@KaziMahbuburRahman
Copy link
Contributor

Title

docs: add example for enabling both AVIF and WebP image formats

Description

What?

This PR enhances the image component documentation by adding examples showing how to enable both AVIF and WebP image formats together in next.config.js. It also updates the image-component example to demonstrate this configuration.

Why?

Currently, the documentation only shows examples for:

  • WebP only (default): formats: ['image/webp']
  • AVIF only: formats: ['image/avif']

However, many developers want to enable both formats together to:

  • Prefer AVIF for browsers that support it (better compression, ~20% smaller files)
  • Fall back to WebP for broader browser compatibility
  • Maximize image optimization across different browsers

This configuration is a best practice but wasn't clearly documented with an example.

How?

  • Added example configuration formats: ['image/avif', 'image/webp'] to App Router image component documentation
  • Added the same example to Pages Router (legacy) image component documentation for consistency
  • Updated examples/image-component/next.config.js to demonstrate the configuration
  • Added clarification that the order matters - Next.js uses the first format in the array that the browser supports

Changes Made

  • docs/01-app/03-api-reference/02-components/image.mdx - Added AVIF + WebP example
  • docs/02-pages/04-api-reference/01-components/image-legacy.mdx - Added AVIF + WebP example
  • examples/image-component/next.config.js - Added formats configuration

Testing

  • Documentation changes only - no code changes
  • Verified examples are syntactically correct
  • Checked that formatting follows Next.js documentation guidelines

Checklist

  • Run pnpm prettier-fix to fix formatting issues (if applicable)
  • Documentation follows the docs guidelines
  • Changes are clear and helpful for developers

… WebP formats. Added configuration examples and clarified caching behavior for multiple formats.
@ijjk ijjk added Documentation Related to Next.js' official documentation. examples Issue was opened via the examples template. labels Nov 16, 2025
@ijjk
Copy link
Member

ijjk commented Nov 16, 2025

Allow CI Workflow Run

  • approve CI run for commit: 6b5d5e6

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

KaziMahbuburRahman and others added 4 commits November 17, 2025 23:51
- Add note about cache overhead when using multiple formats
- Remove redundant note about array order (already mentioned earlier)

Addresses feedback about documenting increased storage requirements
when enabling both AVIF and WebP formats, and removes duplicate
information about format order.
@icyJoseph icyJoseph merged commit 1dd580d into vercel:canary Nov 20, 2025
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Related to Next.js' official documentation. examples Issue was opened via the examples template.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants