Browsersync synchronizes file changes and interactions (scrolls, clicks, form inputs) across multiple devices in real-time during web development.
Installation
# Global CLI installation
npm install -g browser-sync
# Or run on-demand with npx
npx browser-sync start --server
Starting a Static Dev Server
Serve static files and watch HTML/CSS/JS for changes:
browser-sync start --server "public" --files "public/**/*.html, public/**/*.css, public/**/*.js"
Proxying an Existing Backend
Wrap an existing local development server (e.g. Rails, Node, PHP) with live reloading:
browser-sync start --proxy "localhost:3000" --files "**/*.css, **/*.js, **/*.html"
Common CLI Flags
| Option | Description |
|---|---|
--server, -s |
Run a built-in static HTTP file server |
--files, -f |
File paths or glob patterns to monitor |
--port |
Specify custom server port (default 3000) |
--proxy, -p |
Proxy an existing local web address |
--no-open |
Prevent opening a browser window automatically |
--no-notify |
Disable the floating in-browser notification badge |
--tunnel |
Expose server to the web using a public URL |