Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Next.js Fast Refresh

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

In this article, we will learn about the Fast refresh in the NextJS project. Fast Refresh is a new hot reloading experience that gives you instantaneous feedback on edits made to your React components. It is now enabled by default for all projects on Next.js 9.4 or newer.

NextJS is a React-based framework. It has the power to Develop beautiful Web applications for different platforms like Windows, Linux, and mac. The linking of dynamic paths helps in rendering your NextJS components conditionally.

Create NextJS Application: You can create a new NextJS project using the below command:

npx create-next-app gfg

 

Project Structure: It will look like this.

All the NextJs applications with version 9.4 or newer come with the Fast refresh feature that gives you instantaneous feedback on edits made to your React components. 

Example: For this example, we will create a new javascript file in our pages directory with the name ‘gfg.js’ with the below content.

Javascript




import React from 'react'
  
export default function index() {
  return (
    <div>
      <h1>This is File</h1>
    </div>
  )
}

Here we created a simple react component named index and inside this component, we add one heading. Now after running the application if we make any changes in our gfg.js file then the changes will be visible within a second, without losing component state.

Steps to run the application: Run the below command in the terminal to run the app.

npm run dev

Output:

My Personal Notes arrow_drop_up
Last Updated : 05 Jan, 2023
Like Article
Save Article
Similar Reads
Related Tutorials