Chris Nelson explains how LiveState enables a LiveView-like experience for embedded web applications hosted on external pages.
For building conventional “SPA” type web apps in Elixir, LiveView is the perfect choice. But if we are writing an embedded web app or one that is designed to be hosted in a larger web page that we don’t control, LiveView is no longer a viable option.
LiveState is a library designed to give developers a LiveView-like experience while building these types of applications. With LiveState, we no longer have to build an API to handle requests and responses. Instead, we get to handle events and state on the server, just like in LiveView, but in an environment where the front end is not served by Phoenix. In this talk, we’ll learn about LiveState by example. We’ll start with a discussion of what LiveState is and how it works. Next, we’ll work through a simple example embedded web application: an element that will add a comments section to a website. Expect to come away with a good understanding of how you can build these types of applications in Elixir and have fun doing it.
Why it's here
2 people recommend this
What people say. Recommended as a solution for building embedded web applications or integrating Phoenix with frontend frameworks like Svelte.
P
u/POiNTxin r/elixir • Recommends
On “Runes in Sveltekit meets socket in Phoenix”
I'm the author of live_svelte but that's not what I'd recommend for your usecase.
I think you're looking for something like `live_state`. I haven't used it myself but I think it can be the bridge you're looking for.
- https://github.com/launchscout/live_state
- link to this video
On “Would you recommend PETAL over Svelte + Supabase to a noob?”
>How do you use them together? Are you mounting your svelte apps in a liveview page and passing assigns?
There are some good talks about integrating Liveview with React and other frameworks. I think this is the library from the talk i read: https://hexdocs.pm/live\_state/readme.html
And here's the talk:
link to this video