From the course: Master Next.js by Building Scalable Apps with Routing, Databases, and Performance

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Configuring favicon using code

Configuring favicon using code

Now, let's see how we can add code to set favicons. The first question that arises is that how do we generate images or icons using code? Well, with the help of Next.js og library, yes, it really is og, we can generate dynamic images with js or ts code. The next slash og library offers the image response class which is able to take the JSX or TSX code, and with that it can generate images. Since the images will be drawn or designed by code, you can generate images dynamically as well. Let me go to the official document, and I'll open the favicon topic. I'll go to the generate icons using code topic. Here they have mentioned the file naming conventions that we must follow for code generated favicon files. The file name has to be either icon or Apple icon, and the extension can be .js, .ts or .tsx. Now if I scroll a bit more, then we have this example for setting a code generated favicon. So here as you can see, they have imported the image response from next slash og library. And…

Contents