Next.js: importing images

Created on 31 Oct 2016  路  2Comments  路  Source: vercel/next.js

One thing I don't understand is how to import images, what does the src url look like? Anything I try fails with a 404 (Not Found)

Most helpful comment

Yes you can put images in static/ beside your pages/ folder and refer to them in CSS with url(static/myimage.jpg) or html <img src="static/blah.png">. I did the former here: https://github.com/sedubois/realate/blob/master/components/Header.js#L12

All 2 comments

Not tested, but they should be available through /static/{filename} from what I've heard.

Yes you can put images in static/ beside your pages/ folder and refer to them in CSS with url(static/myimage.jpg) or html <img src="static/blah.png">. I did the former here: https://github.com/sedubois/realate/blob/master/components/Header.js#L12

Was this page helpful?
0 / 5 - 0 ratings