正在加载视频...

视频加载失败

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

71,291 次观看 • 1 年前 •via X (Twitter)

10 条评论

Alex Sidorenko 的头像
Alex Sidorenko1 年前

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 的头像
Jarred Sumner1 年前

@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 的头像
Potato Dragon1 年前

so its better to import images for local images?

Anze Koprivec 的头像
Anze Koprivec1 年前

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

Mamad 的头像
Mamad1 年前

very useful

Coding With Mr.M 的头像
Coding With Mr.M1 年前

For me i always import the images it’s best

González J. 的头像
González J.1 年前

lovely, good to know

Thom Knepper 汤姆 的头像
Thom Knepper 汤姆1 年前

BRB updating some projects

fhf 的头像
fhf1 年前

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

Lost Cause 🐗 的头像
Lost Cause 🐗1 年前

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

相关视频