Skip to content
Manuel1471Public

About

Run selected Phoenix LiveView interactions in the browser with Elixir. Keep your HEEx templates and choose which handlers run locally or sync with LiveView.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

LiveLift

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

Handler What happens
@client :local The browser updates the UI without sending a LiveView event after the hook mounts. Use it for previews, filters, or sorting.
@client true The browser predicts the result immediately. LiveView runs the handler on the server and confirms or corrects the result.
Unmarked LiveView 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 counter New project walkthrough
Try LiveLift in an app I already have Opt in one handler
Keep my own JavaScript build or LiveSocket hooks Manual asset integration
Check whether my Elixir and HEEx are supported Language reference

LiveLift is experimental and supports Phoenix LiveView 1.2.x. Install the Hex package, which includes the browser runtime. The installation guide also covers working from a local build. See the release instructions for publication and public verification.

Compatibility

Environment Published requirement or verification target
Elixir and OTP The package declares Elixir ~> 1.15. CI runs Elixir 1.18 with OTP 27 and Elixir 1.20 with OTP 29.
Phoenix The installer and consumer checks use the Phoenix 1.8 layout and the 1.8.16 generator.
Phoenix LiveView The package declares ~> 1.2.0. The compatibility workflow tests 1.2.0 and 1.2.15. A weekly advisory runs against main.
Browsers CI uses Playwright Chromium, Firefox and WebKit. See the browser requirements for the APIs required by the client runtime.

Go deeper

Development

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

About

Run selected Phoenix LiveView interactions in the browser with Elixir. Keep your HEEx templates and choose which handlers run locally or sync with LiveView.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages