https://github.com/lavigneer/browser-autorefresh
A Golang utility that facilitates browser auto-refresh when the server is restarted
https://github.com/lavigneer/browser-autorefresh
autorefresh developer-tools go golang web webserver
Last synced: over 1 year ago
JSON representation
A Golang utility that facilitates browser auto-refresh when the server is restarted
- Host: GitHub
- URL: https://github.com/lavigneer/browser-autorefresh
- Owner: lavigneer
- License: mit
- Created: 2024-11-03T19:52:05.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-23T13:29:45.000Z (over 1 year ago)
- Last Synced: 2025-02-04T22:14:35.130Z (over 1 year ago)
- Topics: autorefresh, developer-tools, go, golang, web, webserver
- Language: Go
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://pkg.go.dev/github.com/lavigneer/browser-autorefresh)
# browser-autorefresh
This is a small Golang utility that can be installed as part of a web server that facilitates browser page auto-refresh when the service is restarted via some live-relaod function
There are two components this utility provides:
1. An http handler for a websocket endpoint
2. A template that provides a JS script to include in a page's html that uses the websocket endpoint to detect when the server is operational.
When the websocket connection is lost, a retry on the client-side occurs until it is able to reconnect, at which point it reloads the page to pull in the latest changes.
This is most useful when combined with a server live reload tool (e.g., [air](https://github.com/air-verse/air)).
# Installation
```bash
go get github.com/lavigneer/browser-autorefresh
```
# Example
See [examples/std](examples/std)