![]() |
Next.js components are integral to building modular and efficient applications, offering tools like Image, Link, Script, and Font to handle media, navigation, scripts, and typography effectively. These components enhance performance and streamline development in Next.js. What is a Component?Components are the building blocks in React-based applications, and Next.js provides a powerful way to work with them. It is reusable and it contains (HTML and JSX) and behavior (JavaScript logic) of a UI element, making it easier to manage and reusable code across different parts of an application. Syntax: <Component_Name /> Image ComponentIn Next.js, There is an Image component that is an evolved from of <img/> element in HTML. It is used for performance optimization which helps in achieving the good core web vitals. It helps to boost Google ranking algorithm, hence improving the ranking of our website. Features:
Props of Image Component: There are the some required props
Example: In this example, we will import the simple image in our page using the Image Component.
Output: Link ComponentLink component is one of the built-in component in Next.js. It is used to create links between the pages in a Next.js app. It is very similar <a/> anchor HTML element. I have written. There are some common props in Link Component
Example 2: In this example, we will create a two js file in page folder one is index.js other is about. In this example, we are using the Page Routing in Next.js Project Structure: Example: This example demostrates the use of link component in next js.
Output: Script ComponentThe <Script> component is a way to include external scripts or libraries in your application. It is often used for loading third-party scripts or adding custom scripts to specific pages. This is a prebuilt Component in Next.js There are the some Commone Props in <Script/> Component
Example:
Font ComponentTo add custom fonts in Next.js, you typically use the next/font package or import fonts in the global CSS. Here’s an example using Google Fonts
Output: |
Reffered: https://www.geeksforgeeks.org
ReactJS |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 15 |