uzaydurdu

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-only adds 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.signal for 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 :slight_smile:

Showing Posts 1 to 5

paulsabou

paulsabou

this is very nice! keep on going! looking fwd to a prod ready version

uzaydurdu

uzaydurdu OP

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 :slight_smile:

paulsabou

paulsabou

i was not aware that it’s already used in real prod envs. i will give it a try!

uzaydurdu

uzaydurdu OP

Hey Elixir folks :waving_hand:

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, @data reaches the chart as a prop, clicking a bar triggers handle_event/3, and Xenia.push_to/4 sends 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-change validation, 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-retry button can restart the component, while on_crash notifies 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 loading: lazy="visible" starts an island when it approaches the viewport.
  • Keyboard shortcuts: shortcuts={%{"mod+s" => "save"}} handles shortcuts while an island has focus.
  • Shared values: consumes: ["theme"] lets JavaScript components follow application-wide values.
  • Connection awareness: consumes: ["connection"] lets an island react when its LiveView disconnects.
  • Server replies: ctx.call is useful for search suggestions and autocomplete.
  • Cleanup: ctx.signal helps cancel requests and remove listeners.
  • Developer tooling: TypeScript adapter types and Xenia.Test for testing props, events, and commands.

Want to try it?

Add Xenia to your dependencies:

# mix.exs
{:xenia, "~> 0.2.0"}

Then run:

mix deps.get

# New application
mix xenia.install

# Existing Phoenix application
mix xenia.install --islands-only

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

uzaydurdu OP

Xenia 0.2.1 is on Hex! :rocket:

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.

  • Cell edits, clicks, row selection, sorting, and filtering are forwarded to handle_event.
  • Rows are tracked by ID, preserving selection, sorting, and filtering when new data arrives.
  • Server-side commands can sort, filter, export CSV, scroll to rows, and change selections.
  • Uses AG Grid Community only. No Enterprise dependency.

FullCalendar

Added on_unselect, so LiveView receives an event when the user clears a date selection.

Bug fix

Xenia.push_to/4 now 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:

{:xenia, "~> 0.2.1"}

I also recorded a 6-minute walkthrough covering all the features, including AG Grid:

Feedback and suggestions for future adapters are always welcome!

— All posts loaded —

Where Next? Top

Trending in News & Updates Top

mat-hek
Popcorn, the library that runs Elixir code in the browser, is now stable :popcorn: This is possible because it now builds on a very stab...
New
bartblast
Hologram UI is in the works - the official component library for Hologram - and the waiting list is now open. A common reaction when I m...
New
bartblast
This thread is for updates on the Hologram website (docs, new pages, roadmap, feature status, etc.). You can watch this thread to get no...
New
mandar1045
Stampede 1.2 is out, and I finally got to try it at a bigger scale. What’s new --find-limit: instead of a fixed number of users, it add...
New
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...
New
rodloboz
Hi all, I’ve just released Sake 0.5.0, and I want to explain better what it’s for, because I think many Phoenix apps can use it now. Wh...
New
Potions
I’m working to make Potions the easiest way to deploy Elixir applications, and the next step in that journey is live: you can now bring y...
New

Other Trending Topics Top

dominicletz
Hey there, I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first. ...
New
raa-ziq
Hi everyone :waving_hand: I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New
kip
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
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