Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

NextJS Fast Refresh

  • Last Updated : 14 Nov, 2021

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:

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!