uzaydurdu
Hey Elixir folks,
I’ve been working on Xenia 0.2.0, and it’s nearly ready.
This release focuses on performance, easier integration, and reliability when using JavaScript libraries with Phoenix LiveView.
What’s new:
-
Code splitting and lazy loading: Components load only when needed. One example page went from 7.9 MB to 0.59 MB of upfront JavaScript.
-
Efficient data updates: A new guide demonstrates incremental updates through commands. Adding one point to a 50,000-point chart sent 99 bytes instead of 585 KB.
-
Easier installation:
mix xenia.install --islands-onlyadds Xenia to existing Phoenix apps without changing their routes or layouts. -
Xenia.Test: ExUnit helpers for testing props, events, and commands.
-
TypeScript support: Typed adapter APIs with JSDoc support.
-
Lifecycle improvements: LiveView connection status and
ctx.signalfor cleanup. -
Forms: Multi-value fields now submit lists compatible with Ecto arrays. This is the only breaking change.
I’ve also updated the examples app with runnable pages showing how the features work, including their source code and browser tests.
Examples: xenia/examples at main · uzaydurdu/xenia · GitHub
Docs: Xenia v0.2.0 — Documentation
Source:
Still wrapping up the release. Feedback is always appreciated. Thanks in advance ![]()
Trending in News & Updates
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #code-sync
- #discussion
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #elixirconf-us
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #security
- #elixirconf-eu
- #processes
- #api
- #forms
- #hex










Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
paulsabou
this is very nice! keep on going! looking fwd to a prod ready version
uzaydurdu
Thanks a lot I appreciate it! Xenia is already designed to be used in real Phoenix applications and I put quite a bit of work into browser tests, lifecycle handling and reliability. But it is still early in terms of adoption though and I’m continuing to improve it before 1.0.
Was there anything specific you would want to see before considering it is actually production ready? It woudl actually help a lot to me. Thank you very much again
paulsabou
i was not aware that it’s already used in real prod envs. i will give it a try!
uzaydurdu
Hey Elixir folks
Have you ever needed a chart, date picker, or code editor in LiveView and ended up writing JavaScript hooks just to connect everything?
How do you make sure your JavaScript components handle their lifecycle safely every time, especially across LiveView updates, navigation, and reconnects?
Aren’t lifecycle issues like missed cleanup, stale state, and duplicate event listeners some of the hardest bugs to track down?
That’s some of the reasons I started working on Xenia.
The idea is to write a small adapter describing how a JavaScript library starts, updates, and stops. Xenia takes care of the repetitive work: props, events, commands, form integration, and lifecycle cleanup.
I wanted to show what that actually looks like, so here are five examples from the examples app, with the code and rendered result side by side.
1. Making a JavaScript chart interactive
Imagine you’re building a dashboard with Chart.js. You want to pass data from LiveView, react when someone clicks a bar, or highlight a particular value from the server.
With Xenia,
@datareaches the chart as a prop, clicking a bar triggershandle_event/3, andXenia.push_to/4sends commands to that particular chart.2. Using a Web Component
Sometimes you find a Web Component and just want to use it in your LiveView page.
Here’s a rating component. Xenia forwards its props directly to the element, so there’s very little adapter code needed.
You can use it as a typed HEEx component and handle its events in LiveView.
3. Using a JavaScript widget in Phoenix forms
Date pickers are easy to display, but integrating them with Phoenix forms, validation, and error messages usually takes more work.
With Xenia, you can use a JavaScript widget with
field={@form[:due]}, much like a regular<.input>.Its value participates in form submission,
phx-changevalidation, and form recovery after reconnecting.4. Handling loading and errors
Some JavaScript libraries take time to initialize, especially when they’re loaded on demand.
Instead of showing an empty area, you can provide a
<:loading>slot. If something fails, an<:error>slot appears.A
data-xenia-retrybutton can restart the component, whileon_crashnotifies LiveView.5. Keeping JavaScript close to where it’s used
Not every JavaScript integration needs to be shared across an entire application.
If a widget belongs to just one page, its adapter can live alongside that page using LiveView’s colocated hooks, without registering it separately in
app.js.A few other things in Xenia 0.2.0
lazy="visible"starts an island when it approaches the viewport.shortcuts={%{"mod+s" => "save"}}handles shortcuts while an island has focus.consumes: ["theme"]lets JavaScript components follow application-wide values.consumes: ["connection"]lets an island react when its LiveView disconnects.ctx.callis useful for search suggestions and autocomplete.ctx.signalhelps cancel requests and remove listeners.Xenia.Testfor testing props, events, and commands.Want to try it?
Add Xenia to your dependencies:
Then run:
There are now 36 examples in the examples app. Each has a runnable page where you can explore the integration and inspect how it’s implemented.
Examples: xenia/examples at main · uzaydurdu/xenia · GitHub
Documentation: Xenia v0.2.0 — Documentation
Hex: xenia | Hex
Source: GitHub - uzaydurdu/xenia: Keep Phoenix in charge, let JavaScript do what it does best: any JS library in LiveView with one small adapter. · GitHub
I’m curious about what other Phoenix developers are doing with JavaScript libraries.
Which libraries are you currently integrating with LiveView? Are there parts of that integration you find unnecessarily complicated?
I’d appreciate any feedback or suggestions. Thanks for taking a look!
uzaydurdu
Xenia 0.2.1 is on Hex!
This release adds our 17th official adapter: AG Grid Community, along with a FullCalendar improvement and a fix for commands sent to removed islands.
What’s new?
AG Grid Community (MIT)
You can now use
<.ag_grid>directly in your LiveView templates, passing rows and AG Grid’s own column definitions written in Elixir.handle_event.FullCalendar
Added
on_unselect, so LiveView receives an event when the user clears a date selection.Bug fix
Xenia.push_to/4now targets only an island that’s still present on the page. Previously, an island whose element had been removed by external JavaScript could still execute the command.Try it
Add to your dependencies:
I also recorded a 6-minute walkthrough covering all the features, including AG Grid:
Feedback and suggestions for future adapters are always welcome!