From the course: Master Next.js: Elaborate Hands-On Web Development, React Basics, Advanced Next.js, and Deployment
Unlock this course with a free trial
Join today to access over 25,200 courses taught by industry experts.
How images optimize with Next.js
From the course: Master Next.js: Elaborate Hands-On Web Development, React Basics, Advanced Next.js, and Deployment
How images optimize with Next.js
All right, so with Next.js, we can serve assets like images in the public directory. In public, we have a favicon. This is an image. We've got the Versal SVG. These are images. So files inside public can be referenced from the root of the application. That's top level, and that's similar to pages. The public directory is also useful for robots.txt, Google site verifications, and any other type of static assets. You can actually look at the documentation specifically for static file serving from the official Next.js homepage to learn more about that. I won't get too deep into that, but what we could do is let's download a picture of ourselves, and we can use the JPEG format, and let's put it in the public directory and save the picture as a profile JPEG in public images directory, and let's add it to the project. So for me, what I'm going to do is I'll just go ahead and open up Photo Booth here. And okay, so I'm having a bit of a crazy hair day, so please excuse that. But I'm just…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
-
(Locked)
Download the CSS starter kit project from Next.js official7m 27s
-
(Locked)
How images optimize with Next.js5m 31s
-
(Locked)
Scripts and header data and props with Next.js6m 58s
-
(Locked)
CSS modules and Next.js optimizations with layout7m 12s
-
(Locked)
Global styling with Next.js4m 47s
-
(Locked)
Customizing utility styles with Next.js9m 55s
-
(Locked)
Metadata for SEO and social media with Next.js6m 43s
-
(Locked)
Writing dynamic layout components with Next.js11m 31s
-
(Locked)
How to use children and props in React and Next.js10m 54s
-
(Locked)
-
-
-