# `Volt.HMR`
[🔗](https://github.com/elixir-volt/volt/blob/v0.22.0/lib/volt/hmr.ex#L1)

Public helpers for broadcasting Volt HMR messages.

These functions are intended for packages that compose Volt's dev server but
own additional source graphs, such as static-site generators. They expose the
same websocket protocol used internally by `Volt.Watcher` without requiring
callers to reach into Volt's registry implementation.

# `broadcast`

Broadcast an HMR message to all connected clients.

# `clear_error`

```elixir
@spec clear_error(
  String.t(),
  keyword()
) :: :ok
```

Clear the errors reported for a source path, hiding the overlay when none remain.

# `document_update`

Ask open pages to check whether their server-rendered HTML changed.

Use this for templates and content, which may affect any page or none. Pages
that carry an entity tag reload only when their HTML changed; see
`Volt.HMR.Document`. Other pages reload.

# `error`

```elixir
@spec error(String.t(), term(), keyword()) :: :ok
```

Report the errors for a source path and show them in connected browsers.

`reason` may be `OXC.Diagnostic` maps, messages, exceptions, or any other term;
see `Volt.Dev.Error.entries/2`. The errors stay current until `clear_error/2`,
so browsers that connect later show them too.

## Options

  * `:session` — the development session. Default: `:default`
  * `:title` — the overlay heading for these errors, such as `"Render error"`.
    Default: `"Build error"`

# `full_reload`

Broadcast a full page reload request for a changed path.

# `invalidate_file`

Invalidate Volt's dev compilation state for a source file without broadcasting.

# `style_update`

Broadcast a style-only update for a changed stylesheet path.

# `update`

```elixir
@spec update(String.t(), [atom() | String.t()], keyword()) :: :ok
```

Broadcast an update for a changed path.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
