shahryarjb

shahryarjb

Hi friends, if you want to create some complex components for example nested and tree drop down select box with search and etc! what option you select?

For example I do not want to send everything from server to client and if I use hook with pure JS, it is not easy to manage for examples more than 200 components (LiveView JS module is good for basic component, not for managing client state edit DOM + project structure even do the limit function in client side not server side)

I see petal using alpine JS or some friends using ReactJS, VueJS and etc.

I just need your suggestion especially a way that is light and developer friendly. imagine you have about 200 components(some of them stateless and the other stateful in client side).

I really need this so that Elixir Developer doesn’t feel like I’m using frontend js frameworks in phoenix LiveView again.:joy:

Thank you in advance.

Showing Posts 1 to 10

bdarla

bdarla

I also use Javascript hooks for such interactions. Indeed, it has some complexity.

Recently, I am thinking to investigate LiveSvelte for this particular part, however, I have not experimented yet.

DaAnalyst

DaAnalyst

I’ve been using AlpineJS with success. There are few integration issues that occurred post LV 0.20.1 but one can work around them.

shahryarjb

shahryarjb OP

Could you name some of these problems please?

shahryarjb

shahryarjb OP

Unfortunately, there is a bit of a learning curve, especially for Elixir developer when customizing!!

If I do it pure with hook I think I am going to taste XSS :smiley: and after 10 or 12 big component I am going to be dived deep inside black hole

I use ReactJS and Nextjs myself.

DaAnalyst

DaAnalyst

Sometimes it happens that the Alpine data in a LiveComponent does not get initialized, so you need to have a simple hook initializing it yourself.

In certain cases, you even need to do this on updates (not just on mounted), or otherwise the JS code crashes. Having to do this on updates may be an issue for in such cases (and I am talking about really complex components e.g. LiveComponents within a stream within LiveComponents within a stream, ..) the data that gets initialized this way with your hook also gets reset.

Personally, I have managed to circumvent all the issues and the app is working really well in a staging environment (AWS/Kubernetes) and overall, I am satisfied with AlpineJS despite those issues with the integration.

Also, I have agreed with an AlpineJS library developer to check a demo of mine once LV 1.0 final is out, so we can at least understand if it’s really a LV issue or an Alpine issue and if possible to make them work smoothly again.

shahryarjb

shahryarjb OP

Could you share some components that you are using Alpine with LiveView hook? if it is possible?

Update

Why you did not use something like svelte that has less size in bundle size? is there any reason?

KP123

KP123

What XSS issues were you experiencing in your hooks implementation?

DaAnalyst

DaAnalyst

Can’t share the components. It’s a proprietary platform. But here’s what I do..

const InitAlpine = {
  mounted() {
    Alpine.initTree( this.el);
  },
  updated() {
    Alpine.initTree( this.el);
  }
};

or

const InitAlpineMounted = {
  mounted() {
    Alpine.initTree( this.el);
  }
};

An item LiveComponent

<div
  id={@id} phx-hook={@mutation == :insert && "InitAlpineMounted"} 
  ..
  x-data=".."
  x-init=".."
>
  ..
</div>

I use Alpine and not svelte because it was given to me as a requirement and at the time I started using it neither myself nor the client were aware of a viable LV-svelte integration (still not sure if there was one).

shahryarjb

shahryarjb OP

It is not about LiveView, I was talking about pure js that I want to create and connect to liveview

2 safe functions can be an unacceptable vulnerable :joy:

superchris

superchris

We’ve had good success using Custom Elements AKA Web Components as a means for integrating client JS with LiveView. We’ve put out LiveElements as a library to make this process easier.

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
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
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
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
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
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

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews