{"id":36488845,"url":"https://github.com/csmith/hotsource","last_synced_at":"2026-01-12T01:53:54.940Z","repository":{"id":296529990,"uuid":"993262332","full_name":"csmith/hotsource","owner":"csmith","description":"Frontend hot reloading in Go","archived":false,"fork":false,"pushed_at":"2025-11-26T12:11:39.000Z","size":938,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-11-29T10:27:03.809Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/csmith.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-30T13:43:33.000Z","updated_at":"2025-11-26T12:11:43.000Z","dependencies_parsed_at":"2025-05-31T22:50:02.371Z","dependency_job_id":"cf396c24-acb7-4939-a961-fd9498fdd309","html_url":"https://github.com/csmith/hotsource","commit_stats":null,"previous_names":["csmith/hotsource"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/csmith/hotsource","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csmith%2Fhotsource","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csmith%2Fhotsource/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csmith%2Fhotsource/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csmith%2Fhotsource/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/csmith","download_url":"https://codeload.github.com/csmith/hotsource/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csmith%2Fhotsource/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28331277,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T00:36:25.062Z","status":"ssl_error","status_checked_at":"2026-01-12T00:36:15.229Z","response_time":60,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-12T01:53:54.875Z","updated_at":"2026-01-12T01:53:54.930Z","avatar_url":"https://github.com/csmith.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hot source: live HTML reloading for Go\n\nHot source provides an easy way to make your web frontend automatically reload\nduring development when you make changes to it.\n\n![demo](demo.avif)\n\n## Why?\n\nAutomatic reloading makes development a lot easier. Being able to have a\nbrowser window visible and update as you make changes in an IDE saves a lot\nof time switching back and forth, manually reloading, and so on. Also, it's just\nfun.\n\nThis sort of live-reloading comes as standard in a lot of JavaScript frameworks,\nbut in Go we're mostly stuck with tools that rerun the entire binary, and\nignore anything going on in the frontend.\n\n## What?\n\nHot source provides a `http.Handler` that injects a cookie and a bit of JavaScript\ninto any request for a HTML file. The JavaScript opens a websocket connection,\nand will cause the browser to reload if it's told to via websocket.\n\nThe handler also tracks any resources requested with its cookie set (i.e., from\nthe same browser session). It adds watchers to those files, and if they're\nupdated it will send the refresh command to the relevant websockets.\n\n## … Maybe?\n\nBut you don't always want live reloading, so there's also a `Maybe` func that\ncan enable or disable hot source based on a boolean. That makes it easy to hook\nit up to a flag, and only enable live reloading in dev mode.\n\nIf you use the `Maybe` func you can even set the `nohotsource` build tag and\nnone of hot source's dependencies will end up in your binary.\n\n## How?\n\nCreate your `http.Handler` as you usually would, and then wrap it in a call to\n`hotsource.Maybe`:\n\n```go\npackage main\n\nimport (\n\t\"embed\"\n\t\"flag\"\n\t\"github.com/csmith/hotsource\"\n\t\"http\"\n\t\"io/fs\"\n)\n\n//go:embed frontend/*.html frontend/*.js frontend/*.png\nvar frontendFS embed.FS\n\nvar hotReload = flag.Bool(\"hot-reload\", false, \"Enable hot reloading\")\n\nfunc main() {\n\tflag.Parse()\n\t\n\tnormalHandler := http.FileServerFS(fs.Sub(frontendFS, \"frontend\"))\n\thotHandler := hotsource.Maybe(normalHandler, \"frontend\", *hotReload)\n\n\thttp.ListenAndServ(\":8080\", hotHandler)\n}\n```\n\n## But…?\n\nThere are some caveats:\n\n- Watchers are never removed, and are always for single files. This will leak\n  resources over time, but it's intended for development use not long term\n  deployment.\n- The way resources are tracked might not be perfect. In particular, if one\n  HTML page loads another HTML page (either via an iframe or something like\n  HTMX), it will end up with a new session ID. I think this will still work\n  properly, but it hasn't been tested.\n\n## Help?\n\nThis is quite rough and ready. Any contributions to tidy it up, add more\nfeatures, improve the documentation, etc, are more than welcome.\n\nIf you use hot source and encounter a bug or problem feel free to raise an\nissue.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsmith%2Fhotsource","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcsmith%2Fhotsource","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsmith%2Fhotsource/lists"}