Next.js Discord

Discord Forum

Import image or direct path

Unanswered
American Chinchilla posted this in #help-forum
Open in Discord
American ChinchillaOP
Quick question. Which is better importing image or use direct image path? I have 11 images in one page including SVG files. Which is the best practise?

5 Replies

for basic svg, it is way better to inline import, but when it gets more complex, imo it still is good (icons should be inlined)... but you mean import where it goves a hash, i personaly just have it in public folder and improt with image path, but they both work
American ChinchillaOP
I am saying

import hero from "public/images/hero.jpg"
<Image src={hero} alt="" width={} height={} />

Or

<Image src="/images/hero.jpg" alt="" width={} height={} />


Which is the best practise? 1 or 2
well i think people would tell you that you shouldn't import from public folder and have it in diferent location, but i personaly use seccond because i don't like the hash at end of name...
i can't say which is better because they both are good
American ChinchillaOP
Okay thank you