Next.js provides an efficient way to manage static assets like images, fonts, icons, and videos, along with powerful built-in image optimization for better performance.
Static assets are stored in the public/ folder.
Files inside this folder can be accessed directly via the browser.
No import required
Path starts from /public
Best for static files
Next.js provides the Image component from next/image for automatic image optimization.
Automatic image optimization
Responsive images
Lazy loading by default
Improved performance and Core Web Vitals
You can also load images from external URLs.
External domains must be allowed in
next.config.js.
The parent container must have position: relative.
Use priority for above-the-fold images.
You can serve:
PDFs
Videos
Audio files
JSON files
Example:
</> data-start="1967" data-end="1976">| Use Case | Recommended | ||
|---|---|---|---|
| Optimized images | next/image | ||
| Simple icons | | ||
| SVG icons | Inline or |