How to Use “Live Server” in VS Code (From Scratch)
If you’re building a website, one of the most useful tools you can have is a “live server.” It opens your project in a browser and automatically refreshes the page every time you save a file. This saves you from having to manually reload the page after every single change.
This guide shows you how to set it all up from scratch using Visual Studio Code (VS Code).
Step 1: Install Visual Studio Code (VS Code)
If you already have VS Code, you can skip to Step 2.
- Go to the official website: https://code.visualstudio.com/
- The site will automatically detect your operating system (Windows, Mac, etc.) and show a big blue “Download” button. Click it.
- Once the download is finished, run the installer. The default options are fine for most users, so you can just click “Next” through the installation steps.
Step 2: Install the “Live Server” Extension
Extensions add new features to VS Code. We’ll add the one that runs our live server.
- Open Visual Studio Code.
- Look at the vertical toolbar on the far left side of the window. Click the icon that looks like four squares (this is the Extensions view).
- A new panel will open with a search bar at the top. Type
Live Serverinto the search bar. - The top result should be named “Live Server” and the author will be Ritwick Dey. This is the one you want!
- Click the blue “Install” button next to it. It will install in just a few seconds.
Step 3: Create a Project and Use Live Server
Now let’s see it in action!
- Create a Project Folder: On your computer (e.g., on your Desktop), create a new folder. Let’s name it
my-test-site. - Create an HTML File: Inside that
my-test-sitefolder, create a new file namedindex.html. You can add some simple HTML to it, like this:<!DOCTYPE html> <html> <head> <title>My Live Server Test</title> </head> <body> <h1>Hello, World!</h1> </body> </html> - Open the Folder in VS Code:
- In VS Code, go to the top menu and click
File > Open Folder.... - Navigate to and select the
my-test-sitefolder you just created.
- In VS Code, go to the top menu and click
- Go Live!
- Now that your folder is open, look at the very bottom-right corner of the VS Code window. You should see a button that says “Go Live”.
- Click it!
Your default web browser will automatically open a new tab showing your index.html page.
Step 4: See the Magic!
- Arrange your windows so you can see both VS Code and your browser at the same time.
- In VS Code, change the text inside the
<h1>tag from “Hello, World!” to something else, like “Live Server is awesome!”. - Save the file (press
Ctrl+SorCmd+S).
The moment you save, the web page in your browser will instantly update to show the new text without you having to do anything! This simple feature will save you tons of time and make web development much smoother.