Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

A project for live-reload functionality for Phoenix during development.


You can use phoenix_live_reload in your projects by adding it to your mix.exs dependencies:

def deps do
  [{:phoenix_live_reload, "~> 1.3"}]

You can configure the reloading interval in ms in your config/dev.exs:

# Watch static and templates for browser reloading.
config :my_app, MyAppWeb.Endpoint,
  live_reload: [
    interval: 1000,
    patterns: [

The default interval is 100ms.


This project uses FileSystem as a dependency to watch your filesystem whenever there is a change and it supports the following operating systems:

  • Linux via inotify (installation required)
  • Windows via inotify-win (no installation required)
  • Mac OS X via fsevents (no installation required)
  • FreeBSD/OpenBSD/~BSD via inotify (installation required)

There is also a :fs_poll backend that polls the filesystem and is available on all Operating Systems in case you don't want to install any dependency. You can configure the :backend in your config/config.exs:

config :phoenix_live_reload,
  backend: :fs_poll

By default the entire application directory is watched by the backend. However, with some environments and backends, this may be inefficient, resulting in slow response times to file modifications. To account for this, it's also possible to explicitly declare a list of directories for the backend to watch (they must be relative to the project root, otherwise they are just ignored), and additional options for the backend:

config :phoenix_live_reload,
  dirs: [
    "../another_project/priv/static", # Contents of this directory is not watched
    "/another_project/priv/static", # Contents of this directory is not watched
  backend: :fs_poll,
  backend_opts: [
    interval: 500

Skipping remote CSS reload

All stylesheets are reloaded without a page refresh anytime a style is detected as having changed. In certain cases such as serving stylesheets from a remote host, you may wish to prevent unnecessary reload of these stylesheets during development. For this, you can include a data-no-reload attribute on the link tag, ie:

<link rel="stylesheet" href="" data-no-reload>

Differences between Phoenix.CodeReloader

Phoenix.CodeReloader recompiles code in the lib directory. This means that if you change anything in the lib directory (such as a context) then the Elixir code will be reloaded and used on your next request.

In contrast, this project adds a plug which injects some JavaScript into your page with a WebSocket connection to the server. When you make a change to anything in your config for live_reload (JavaScript, stylesheets, templates and views by default) then the page will be reloaded in response to a message sent via the WebSocket. If the change was to an Elixir file then it will be recompiled and served when the page is reloaded. If it is JavaScript or CSS, then only assets are reloaded, without triggering a full page load.


Same license as Phoenix.