Skip to content

How to reload the browser window when you save a file

A quick and simple approach

I was working on a website in vanilla HTML + JS, and I missed one of the best feature provided by those quick start packages like create-react-app or the Vue CLI: reloading the page when I saved a file in the code editor.

The simplest way I found is to install browser-sync:

npm install -g browser-sync

then run it in your project folder:

browser-sync start --server --files "."

The above command watches all files in the current folder (and all subfolders) for changes, and launches a web server on port 3000, opening a browser window to connect to the server.

Any time you change a file, the browser will refresh.

Very useful while prototyping!

THE VALLEY OF CODE

THE WEB DEVELOPER's MANUAL

You might be interested in those things I do:

  • Learn to code in THE VALLEY OF CODE, your your web development manual
  • Find a ton of Web Development projects to learn modern tech stacks in practice in THE VALLEY OF CODE PRO
  • I wrote 16 books for beginner software developers, DOWNLOAD THEM NOW
  • Every year I organize a hands-on cohort course coding BOOTCAMP to teach you how to build a complex, modern Web Application in practice (next edition February-March-April-May 2024)
  • Learn how to start a solopreneur business on the Internet with SOLO LAB (next edition in 2024)
  • Find me on X

Related posts that talk about :