Skip to content

An alternative to browsersync and 5server written in Go. Generates a web server for your HTML project and reloads when files change. I built this for Zed but would work in most / all IDEs that support custom tasks.

License

Notifications You must be signed in to change notification settings

teamcoltra/5browsersync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

5browsersync

A lightweight, fast, and simple browser sync tool written in Go. Automatically reloads your browser or refreshes CSS when files change in your project directory. Designed for rapid development workflows with minimal configuration.

5browsersync is named after its inspiration: 5server from VSCode and BrowserSync which is a cool tool but I didn't want to install NPM and manage all that.

You can just download the binary from the releases page. No need to build it yourself unless you want to.

Features

  • Automatic Browser Reload: Watches files and reloads the browser via WebSocket when changes are detected.
  • CSS Hot Reload: Refreshes stylesheets without a full page reload.
  • HTML Script Injection: Injects a sync script into served HTML files for seamless integration.
  • Configurable via CLI: Flexible command-line options for directory, address, throttling, debounce, ignores, and more.
  • Cross-platform: Runs anywhere Go is supported.
  • Minimal Dependencies: Only uses fsnotify for file watching.

Installation

Download Binary

Download the binary from the releases page.

Build from Source

  1. Clone the repository:

    git clone https://github.com/teamcoltra/5browsersync.git
    cd 5browsersync
  2. Build the binary:

    go build -o 5browsersync ./cmd/5browsersync
  3. (Optional) Install globally:

    go install ./cmd/5browsersync

Usage

Start the sync server in your project directory:

./5browsersync --dir . --open
  • By default, serves files from the current directory and injects the sync script into HTML files.
  • Automatically opens your default browser to the server address if --open is specified.

Configuration

Command-line flags:

Flag Description Default
--dir Directory to serve and watch .
--addr Address to bind (host:port) :8080
--open Open browser on start false
--throttle Minimum ms between reloads 0
--latency Artificial latency before reload 0s
--debounce Debounce interval for file events 0s
--noinject Disable HTML script injection false
--ignores Ignore patterns (can repeat)
--cors Enable permissive CORS headers false

Example:

./5browsersync --dir ./public --addr :3000 --open --ignores node_modules --debounce 200ms

Contributing

Contributions are welcome! Please open issues or submit pull requests for bug fixes, features, or documentation improvements.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/my-feature)
  3. Commit your changes (git commit -am 'Add new feature')
  4. Push to the branch (git push origin feature/my-feature)
  5. Open a pull request

License

This project is licensed under the MIT License. See LICENSE for details.

Zed Integration

Zed doesn't yet have a native task runner UI like VS Code, but it does support custom command-line tasks via .zed/tasks.json.


Step-by-Step: Add a 5browsersync Task to Zed

  1. Open your project in Zed

  2. Create a .zed/tasks.json file in the root of your project if it doesn't already exist:

    mkdir -p .zed
    touch .zed/tasks.json
  3. Add the following content to .zed/tasks.json:

    {
      "tasks": [
        {
          "name": "Start 5browsersync",
          "cmd": ["5browsersync", "--dir", ".", "--open"],
          "cwd": "${projectRoot}"
        }
      ]
    }
    • name: Will be the label shown in the task palette.
    • cmd: What Zed will execute.
    • cwd: The current working directory — using ${projectRoot} will always run it in the current project folder.

How to Run It

  • Press Cmd + Shift + P (or Ctrl + Shift + P on Windows/Linux) to open the Command Palette
  • Type: Tasks: Run Task
  • Select: Start 5browsersync

Extra Tips

  • You can change --dir to point to a subdirectory like public/ if that's where your files live.

  • If you always want CORS or debounce, just add the flags in cmd, like:

    "cmd": ["5browsersync", "--dir", ".", "--open", "--cors", "--debounce", "300ms"]
  • Make sure 5browsersync is in your system $PATH. You can test this by running 5browsersync --help in your terminal.


Contact

For questions, suggestions, or support:

About

An alternative to browsersync and 5server written in Go. Generates a web server for your HTML project and reloads when files change. I built this for Zed but would work in most / all IDEs that support custom tasks.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published