Loading video...

Video Failed to Load

Go Home

Importing local images vs referencing them from "/public" folder in Next.js

71,291 views • 1 year ago •via X (Twitter)

10 Comments

Alex Sidorenko's profile picture
Alex Sidorenko1 year ago

When using imports for local images: - Next automatically determines width and height, so no need to set it manually - Next hashes the file contents and sets high max-age for cache-control so images are cached in browser (faster load / lower serverless bill)

Jarred Sumner's profile picture
Jarred Sumner1 year ago

@leerob have you thought about making it so the image can be a component itself? It can implement toString which would preserve backwards compatibility both with <Image /> and for string usage

Potato Dragon's profile picture
Potato Dragon1 year ago

so its better to import images for local images?

Anze Koprivec's profile picture
Anze Koprivec1 year ago

Don’t most hosting providers just cache these at the CDN level anyway?

Mamad's profile picture
Mamad1 year ago

very useful

Coding With Mr.M's profile picture
Coding With Mr.M1 year ago

For me i always import the images it’s best

González J.'s profile picture
González J.1 year ago

lovely, good to know

Thom Knepper 汤姆's profile picture
Thom Knepper 汤姆1 year ago

BRB updating some projects

fhf's profile picture
fhf1 year ago

Sum up, don't put images in the public dir

Lost Cause 🐗's profile picture
Lost Cause 🐗1 year ago

Lets add another variable as "output: standalone" and this post is rather misleading

Related Videos