Video wird geladen...

Video konnte nicht geladen werden

Zur Startseite

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

71,291 Aufrufe • vor 1 Jahr •via X (Twitter)

10 Kommentare

Profilbild von Alex Sidorenko
Alex Sidorenkovor 1 Jahr

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)

Profilbild von Jarred Sumner
Jarred Sumnervor 1 Jahr

@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

Profilbild von Potato Dragon
Potato Dragonvor 1 Jahr

so its better to import images for local images?

Profilbild von Anze Koprivec
Anze Koprivecvor 1 Jahr

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

Profilbild von Mamad
Mamadvor 1 Jahr

very useful

Profilbild von Coding With Mr.M
Coding With Mr.Mvor 1 Jahr

For me i always import the images it’s best

Profilbild von González J.
González J.vor 1 Jahr

lovely, good to know

Profilbild von Thom Knepper 汤姆
Thom Knepper 汤姆vor 1 Jahr

BRB updating some projects

Profilbild von fhf
fhfvor 1 Jahr

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

Profilbild von Lost Cause 🐗
Lost Cause 🐗vor 1 Jahr

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

Ähnliche Videos