I can't reference an image in Next.js
/public/favicon/mail.png
=> "/favicon/mail.png" will work
How to display an Image with next.js?
assets
directory and all static (images, icons, fonts, robot.txt...) stuff should be inside the public
folder to be accessible.
Relevant docs.
Nextjs: Unable to load images from static folder
from the docs:
Next.js can serve static files, like images, under a folder calledSo, first add an image to
public in the root directory. Files inside public can then be
referenced by your code starting from the base URL (/).
public/my-image.png
and then you can reference it:<img src="/my-image.png" />
I think next.js will have a watch on this directory so you won't need to restart
your server every time you put something in there. Can't display Image in Image tag while using Next.js and material UI
To load static images, first import the file. E.gimport ProfileSvg from "/images/Profile.svg"
Then in your image.
<Image
src={ProfileSvg}
alt={"Thumbnail-alt"}
width={300}
height={160}
style={{ background: "#252525e6", borderRadius: "6px" }}
/>
Nextjs Image component does not work with external URL of image source
Restart the nextjs server each time you change the config file, next.config.js
.
Cannot import image in NextJs project
Changed the import FeaturesBg from '/images/features-bg.png'
to const FeaturesBg = '/images/features-bg.png'
and nextjs relative /public
static imports worked.
New NextJS project not displaying images
you must put image in Public folder and in Src img write "/logo.png"
if you work on Nextjs , stady Image/Next
Related Topics
Removing Duplicate Objects with Underscore for JavaScript
Javascript: Dynamically Creating Variables for Loops
Intercept Paste Event in JavaScript
JavaScript Get Object Key Name
Using Fetch API to Access JSON
Access 'Data-' Attribute Without Jquery
Jquery Convert Line Breaks to Br (Nl2Br Equivalent)
Typeerror: Illegal Invocation on Console.Log.Apply
Pass Parameter with Python Flask in External JavaScript
Why Let and Var Bindings Behave Differently Using Settimeout Function
How to Change the Pop-Up Position of the Jquery Datepicker Control
Google Map API - Multiple Icons in Wrong Spot
Cannot Set Property 'Innerhtml' of Null
How to Calculate the Number of Years Between Two Dates