0
0
Remixframework~10 mins

Dev server and hot module replacement in Remix - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Dev server and hot module replacement
Start Dev Server
Watch Files for Changes
File Change Detected?
NoWait
Yes
Apply Hot Module Replacement
Update Browser Without Full Reload
Continue Watching
The dev server starts and watches your files. When a file changes, it updates only that part in the browser without reloading the whole page.
Execution Sample
Remix
import { useState } from 'react';

export default function Counter() {
  const [count, setCount] = useState(0);
  return <button onClick={() => setCount(count + 1)}>{count}</button>;
}
A simple counter component that updates state and UI. When saved, the dev server updates this component instantly using hot module replacement.
Execution Table
StepActionFile Change DetectedHMR AppliedBrowser Update
1Start dev serverNoNoInitial page load
2User edits Counter componentYesYesUpdate Counter button text without full reload
3User clicks buttonNoNoCount increments and UI updates
4User edits Counter component againYesYesUpdate Counter button text instantly
5No further changesNoNoIdle, waiting for changes
💡 Dev server runs continuously, waiting for file changes to apply HMR.
Variable Tracker
VariableStartAfter Step 3After Step 5
count011
Key Moments - 2 Insights
Why doesn't the whole page reload when I save changes?
Because the dev server detects the file change and applies Hot Module Replacement (HMR), updating only the changed module (see execution_table steps 2 and 4). This keeps the app state and UI updated instantly without a full reload.
What happens if I change a file that cannot be hot replaced?
The dev server will perform a full page reload to apply changes. This is not shown in this trace but is the fallback when HMR is not possible.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what happens at step 2 when the Counter component is edited?
AThe dev server reloads the entire page
BHot Module Replacement updates the Counter button text without full reload
CNothing happens because no file change is detected
DThe browser crashes
💡 Hint
Check the 'HMR Applied' and 'Browser Update' columns at step 2 in the execution_table
According to the variable tracker, what is the value of 'count' after step 3?
A0
B2
C1
DUndefined
💡 Hint
Look at the 'count' row in variable_tracker after step 3
If the user edits the Counter component multiple times without clicking the button, what stays the same according to the tables?
AThe 'count' variable value
BThe dev server stops watching files
CThe browser reloads fully each time
DThe button stops working
💡 Hint
See variable_tracker and execution_table steps 2 and 4 for file edits without clicks
Concept Snapshot
Dev server watches your files for changes.
When a change happens, Hot Module Replacement (HMR) updates only the changed parts.
This updates the browser instantly without a full reload.
Keeps app state intact and speeds up development.
If HMR can't apply, a full reload happens as fallback.
Full Transcript
The dev server starts and watches your project files. When you save a change, it detects the file update. Instead of reloading the whole page, it uses Hot Module Replacement to update only the changed module in the browser. This means your app updates instantly and keeps its current state. For example, editing a Counter component updates the button text without losing the count. Clicking the button changes the count state and updates the UI normally. The dev server keeps running, waiting for more changes. If a file change cannot be hot replaced, the server reloads the full page as a fallback. This process helps developers see changes quickly and keeps their work smooth.