victor23k

victor23k

LiveViewPortal is a small library that allows third-party sites to embed LiveView apps.
The library is distributed as an NPM package. Only a small part of the LiveView JS code is modified.

What problem does this solve?

From the LiveView repo:

Phoenix LiveView enables rich, real-time user experiences with server-rendered HTML.

This matches Doofinder’s use case for our ecommerce products except for one point: rendering LiveViews from third party pages. We needed to embed LiveView for everybody that wanted to give their users rich and real-time experiences.

We have been using a modified version of LiveView with this purpose for a long time. We wanted to extend this to other projects and decided to make it open source. Our goal is to make this feature a part of LiveView, and we are working on merging this to LiveView. In the mean time, you can use this library to try it out.

If you want to know more about the technical details, you can check out the repo and our blog post. Also, if you have any questions, I’ll be more than happy to answer here!

https://github.com/doofinder/live_view_portal

Showing Posts 1 to 10

hectorperez

hectorperez

Amazing job, @victor23k!
Excited to see what use cases the community comes up with!

shankardevy

shankardevy

Great job! I wanted to do this for sometime but never managed to do it myself! I had a similar one done for a comment server alternative for Disqus that I did for an organisation using LiveView but with a lot of hacks. However something like what you have with LVPortal would make it easier to implement without the ugly hacks. Congrats on making this available for everyone!

victor23k

victor23k OP

Thanks!! This has some minimal hacks, as it modifies javascript LiveView code. Hopefully we can find a way to make this available in LiveView.

The comment solution is definitely a great idea, I’m sure you must have been happy once you managed to implement that with all the workarounds that you mention :smile:.

jaimeiniesta

jaimeiniesta

Woah, thanks for releasing this, it looks awesome. :purple_heart:

I will try it soon. I can think of many uses for embedding live counters and reports from Rocket Validator into our users’ sites. :rocket:

sezaru

sezaru

Amazing work! This will be very useful with the stuff we are planning to do in the company I work!

Here are some questions, do you already have an github issue in the LV or Phoenix github repo asking to merge this so I can follow it?

I’m not sure if this is possible with shadow dom or not, but how do you handle navigate and patch? Is it possible to change the page URL?

rhcarvalho

rhcarvalho

Very nice! Several potential upstream contributions!
Thanks for sharing :purple_heart:

Is it viable to use LiveViewPortal and regular LiveView (for other pages in the same app) simultaneously?

sonic182

sonic182

Hi @rhcarvalho

Yes It is possible, that’s one of our use cases where we embed a chat in Doofinder admin panel (two distinct phoenix apps)

victor23k

victor23k OP

@sezaru thanks!

Not yet, but I’ll post the PR in this thread so you and others can follow the progress.

I have not explored this yet, but it is definitely something to experiment with. It can be tricky to modify the URL as the host page would probably also do things with the URL. Also you would probably want to reuse the same websocket instead of navigating to a new LiveView and having to mount again. I think live_session could be of use here.

victor23k

victor23k OP

Hey @rhcarvalho, thanks. As @sonic182 said, you can embed a LiveViewPortal inside a LiveView hosted in a different Phoenix app.

Also, you can serve, from the same Phoenix app, both regular LiveViews and LiveViewPortals. For that, you can define separate socket endpoints and router pipelines.

rhcarvalho

rhcarvalho

Excellent questions from @sezaru.

Since we touched the topic of navigation, I’d like to ask how is LiveViewPortal different from LiveView when it comes to state management options? IIUC URL params are not available, are they?

How is the redeployment/reconnection experience? In particularly, with regards to state preservation, e.g. form inputs.

Where Next? Top

Trending in Announcing Top

woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. https://github.com/woylie/doggo Features Unstyled Phoenix components....
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
anuaralfetahe
Hello Published a new library - ProcessHub! ProcessHub is a library designed to manage process distribution within the Elixir cluster. ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
sergio
It’s not that it’s vocabulary is too advanced. It’s something worse. I get lost trying to follow even a paragraph written by Claude. It’...
New
AstonJ
This showed up on my feed.. anyone heard of it? Just hype? Ox Alpha is a reasoning model designed for coding, sustained ag...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews