
- Next.js - Home
- Next.js - Overview
- Next.js - Project Setup
- Next.js - Folder Structure
- Next.js - App Router
- Next.js - Page Router
- Next.js Features
- Next.js - Pages
- Next.js - Data Fetching
- Next.js - ISR
- Next.js - Static File Serving
- Next.js - Pre-Rendering
- Next.js - Partial Pre Rendering
- Next.js - Server Side Rendering
- Next.js - Client Side Rendering
- Next.js Routing
- Next.js - Routing
- Next.js - Nested Routing
- Next.js - Dynamic Routing
- Next.js - Parallel Routing
- Next.js - Imperative Routing
- Next.js - Shallow Routing
- Next.js - Intercepting Routes
- Next.js - Redirecting Routes
- Next.js - Navigation and Linking
- Next.js Configuration
- Next.js - TypeScript
- Next.js - Environment Variables
- Next.js - File Conventions
- Next.js - ESLint
- Next.js API & Backend
- Next.js - API Routes
- Next.js - Dynamic API Routes
- Next.js - Route Handlers
- Next.js - API MiddleWares
- Next.js - Response Helpers
- Next.js API Reference
- Next.js - CLI Commands
- Next.js - Functions
- Next.js - Directives
- Next.js - Components
- Next.js - Image Component
- Next.js - Font Component
- Next.js - Head Component
- Next.js - Form Component
- Next.js - Link Component
- Next.js - Script Component
- Next.js Styling & SEO
- Next.js - CSS Support
- Next.js - Global CSS Support
- Next.js - Meta Data
- Next.js Advanced Topics
- Next.js - Error Handling
- Next.js - Server Actions
- Next.js - Fast Refresh
- Next.js - Internationalization
- Next.js - Authentication
- Next.js - Session Management
- Next.js - Authorization
- Next.js - Caching
- Next.js - Data Caching
- Next.js - Router Caching
- Next.js - Full Route Caching
- Next.js - Request Memoization
- Next.js Performance Optimization
- Next.js - Optimizations
- Next.js - Image Optimization
- Next.js - Lazy Loading
- Next.js - Font Optimization
- Next.js - Video Optimization
- Next.js - Script Optimization
- Next.js - Memory Optimization
- Next.js - Using OpenTelemetry
- Next.js - Package Bundling Optimization
- Next.js Testing
- Next.js - Testing
- Next.js - Testing with Jest
- Next.js - Testing with Cypress
- Next.js - Testing with Vitest
- Next.js - Testing with Playwright
- Next.js Debugging & Deployment
- Next.js - Debugging
- Next.js - Deployment
- Next.js Useful Resources
- Next.js - Interview Questions
- Next.js - Quick Guide
- Next.js - Useful Resources
- Next.js - Discussion
Next.js - Fast Refresh
Fast Refresh
Fast Refresh is a React feature integrated to Next.js that allows you to update your code and see the changes in real-time without having to refresh the page. This is a great feature for developers who are working on large applications or who want to see the changes they make in their code immediately.
How Fast Refresh works?
- If you edit a file that only exports React component(s), Next.js will update the code only for that file, and re-render your component.
- If you edit a file with exports that aren't React components, Next.js will re-run both that file, and the other files importing it. So if both Button.js and Modal.js import theme.js, editing theme.js will update both components.
- Finally, if you edit a file that's imported by files outside of the React tree, Fast Refresh will fall back to doing a full reload. You might have a file which renders a React component but also exports a value that is imported by a non-React component. In this case, Fast Refresh will re-run the entire application.
Features of Fast Refresh
- Real-Time Updates: Changes to components or styles are applied immediately, maintaining component state and avoiding full page reloads.
- Automatic Activation: Fast Refresh is enabled by default in Next.js, no extra configuration is needed.
- State Preservation: Fast Refresh retains component state across updates, improving development workflow and reducing the need for manual refreshes.
Example of Fast Refresh
From the Next.js 9 onwards, Fast Refresh is enabled by default. So if you make any changes to your code, you will see the changes immediately. Here we defined a simple Next.js home page to demonstrate the Fast Refresh feature.
// File: app/page.tsx export default function Home() { return ( <div> <h1>Home Page</h1> <p>This is the home page.</p> </div> ); }
Output

Disable Fast Refresh
In Next.js, Fast Refresh is enabled by default in development mode. If you need to disable Fast Refresh, you can do so by modifying the Next.js configuration. Open your next.config.js file (create one if it doesn't exist) and add the following line:
// File: next.config.js module.exports = { experimental: { reactRefresh: false, }, };