Ring middleware for hot reload of server-rendered applications.
Ring middleware for hot reload of server-rendered applications.
(deregister-notify-fn! f)Removes a previously registered notification function.
Removes a previously registered notification function.
(notify!)Triggers a reload notification to all registered listeners. Used by the nREPL middleware.
Triggers a reload notification to all registered listeners. Used by the nREPL middleware.
(register-notify-fn! f)Registers a notification function. Called by the middleware on setup so that the nREPL middleware can trigger reloads.
Registers a notification function. Called by the middleware on setup so that the nREPL middleware can trigger reloads.
(wrap-hot-reload handler
&
[{:keys [watch-paths watch-extensions uri-prefix inject?
debounce-ms bust-css-cache?]
:or {watch-paths ["src"]
watch-extensions #{".cljc" ".html" ".css" ".clj" ".edn"}
uri-prefix "/__hot-reload"
inject? (constantly true)
debounce-ms 100
bust-css-cache? false}}])Ring middleware that provides hot reload for server-rendered HTML responses.
Watches file system paths for changes and notifies connected browsers via WebSocket. The browser re-fetches the page and morphs the DOM in place.
Options: :watch-paths - directories to watch (default ["src"]) :watch-extensions - file extensions to trigger reload (default #{"clj" ".cljc" ".edn" ".html" ".css"}) :uri-prefix - WebSocket endpoint path (default "/__hot-reload") :inject? - predicate (fn [request response]) controlling injection (default: always inject into HTML responses) :debounce-ms - debounce window in ms (default 100) :bust-css-cache? - append cache-busting param to stylesheet URLs on reload (default false). Useful when serving plain CSS without Vite or hashed filenames.
Lifecycle: The caller is responsible for starting/stopping the watcher. This middleware returns a map with: :handler - the Ring handler to use :watcher - the Watcher instance :start! - fn [] that starts watching; returns a handle :stop! - fn [handle] that stops watching :notify! - fn [] that manually triggers a reload
Ring middleware that provides hot reload for server-rendered HTML responses.
Watches file system paths for changes and notifies connected browsers via
WebSocket. The browser re-fetches the page and morphs the DOM in place.
Options:
:watch-paths - directories to watch (default ["src"])
:watch-extensions - file extensions to trigger reload
(default #{"clj" ".cljc" ".edn" ".html" ".css"})
:uri-prefix - WebSocket endpoint path (default "/__hot-reload")
:inject? - predicate (fn [request response]) controlling injection
(default: always inject into HTML responses)
:debounce-ms - debounce window in ms (default 100)
:bust-css-cache? - append cache-busting param to stylesheet URLs on
reload (default false). Useful when serving plain CSS
without Vite or hashed filenames.
Lifecycle: The caller is responsible for starting/stopping the watcher.
This middleware returns a map with:
:handler - the Ring handler to use
:watcher - the Watcher instance
:start! - fn [] that starts watching; returns a handle
:stop! - fn [handle] that stops watching
:notify! - fn [] that manually triggers a reloadcljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |