Elixir interactions in the browser, inside Phoenix LiveView.

Keep your HEEx and handle_event/3. Add use LiveLift to a LiveView or LiveComponent and mark the handlers you want to run in the browser.

Try the demo · Add to a Phoenix app · How it works

LiveLift demo showing a local score of 12, one LiveView server event, and a saved score of 12

The score changes in the browser. LiveView handles server activity and saves the score when you sync it.

One handler, three ways to run it

HandlerWhat happens
@client :localThe browser updates the UI without sending a LiveView event after the hook mounts. Use it for previews, filters, or sorting.
@client trueThe browser predicts the result immediately. LiveView runs the handler on the server and confirms or corrects the result.
UnmarkedLiveView handles the event on the server. Use this for persistence, permissions, or external calls.

This counter uses ordinary HEEx and a local handler.

defmodule MyAppWeb.Counter do
  use Phoenix.LiveComponent
  use LiveLift

  def render(assigns) do
    ~H"""
    <button type="button" phx-click="increment" phx-target={@myself}>
      Count: {@count}
    </button>
    """
  end

  @client :local
  def handle_event("increment", _params, socket) do
    {:noreply, update(socket, :count, &(&1 + 1))}
  end
end

Mount it from a LiveView with <.live_component module={MyAppWeb.Counter} id="counter" count={0} />. See the native component guide for supported handlers.

Try the demo

Run these commands from the repository root.

cd examples/demo
mix setup
mix phx.server

Open the demo at localhost:4000 to try the score and task list from the screenshot. Visit /local-actions to compare all three event modes on one page. See the demo guide for more examples.

Add LiveLift to a Phoenix app

I want to…Start here
Create a Phoenix app and see a working counterNew project walkthrough
Try LiveLift in an app I already haveOpt in one handler
Keep my own JavaScript build or LiveSocket hooksManual asset integration
Check whether my Elixir and HEEx are supportedLanguage reference

LiveLift 0.1.0-rc.1 is an experimental first release candidate for Hex and targets Phoenix LiveView 1.2.x. The installation guide covers trying it from a local package and installing from Hex once available. See the release instructions for publication and public verification.

Go deeper

Development

mix deps.get
npm ci --prefix bench
mix test
npm test --prefix assets