Serve A Local Directory As A Web Site With npx browser-sync

August - 2021

You can serve a local directory as a web site by running this inside it:

npx browser-sync start --server --files "./*.html" --no-open --no-notify --directory

This will only server html files. Serving different ones is left as an exercise to the reader.

The site is served at both:


Use ngrok if you need to show it to folks externally by running this (doesn't have to be in the same directory):

ngrok http 3000

There's also a UI that gives you some details at:


You'll need npx installed which should come with node.

It'll install browser-sync the first time you run it if it's not already there.