uzaydurdu
Hey everyone!
I’ve been working on an open-source library called Xenia, and I’ve finally released version 0.1.0. I wanted to share it here and hear what you think.
The idea came from something I kept running into while building Phoenix LiveView applications.
Whenever I wanted to use a JavaScript library like Monaco, Chart.js, or a rich-text editor, I had to write another hook, handle updates, communicate with LiveView, clean up instances, and make sure everything still worked after navigation.
It’s all doable, of course, but I found myself repeating a lot of the same work.
So I started building Xenia.
The idea is simple: Phoenix stays in charge of the application and its state, while JavaScript libraries handle the browser-specific things they’re good at. Xenia takes care of the integration between them.
You can write an adapter for a JavaScript library once, reuse it across projects, and extend it when you need something different.
For example, using Monaco in a LiveView looks like this:
<.monaco id="editor" value={@code} on_change="code_changed" />
Xenia handles the lifecycle, prop updates, events, and cleanup behind the scenes.
What ended up in Xenia
It started with JavaScript adapters, but while building it I also added a few things to make working with LiveView applications easier.
Here’s what’s included so far:
-
Reusable JavaScript adapters: 16 official integrations covering Monaco, Tiptap, Chart.js, D3, FullCalendar, Leaflet, xterm, WaveSurfer, and more. You can configure and extend them, or write an adapter for any other JavaScript library.
-
Props, events, commands, and server replies: Pass assigns to JavaScript, send events back to LiveView, call server handlers and receive replies, or tell a specific component to do something.
-
Forms: Use JavaScript-powered components as regular Phoenix form fields, including validation, changes, reconnects, and server corrections.
-
File-based routing and nested layouts: Add
page.exandlayout.exfiles to an app folder. Xenia generates ordinary Phoenix LiveView routes. -
Persistent components and shared LiveViews: Keep things like sidebars, editors, or audio players alive while navigating, or share a LiveView process between related pages.
-
Colocated adapters: Keep JavaScript that’s only needed by one page directly next to that page.
-
Providers and keyboard shortcuts: Share things like themes or locale values across components, and handle shortcuts while an island has focus.
-
Loading and error states: Show loading content while a library initializes, handle failures, retry, and report crashes without writing that logic in every adapter.
-
Icons, notifications, and languages: The examples show Iconify and Heroicons, success/error/info notifications using Phoenix flash, and English/German translations using Gettext. Translated labels can also be passed into JavaScript components without remounting them.
-
A few other conveniences: Page metadata, Open Graph tags, sitemap generation, component and page generators, and
mix xenia.installto get started with a new Phoenix application.
Pages from folders
One feature I particularly wanted was a simpler way to organize pages.
For example:
lib/my_app_web/app/
layout.ex
(auth)/
layout.ex
persistent.ex
editor/
page.ex
The folder structure determines the route and layout hierarchy. The persistent.ex can keep something like a sidebar alive when moving between pages.
The (auth) folder is a route group; authentication itself still uses explicit Phoenix hooks.
And underneath, it’s still normal Phoenix. Things like mix phx.routes, ~p, LiveView hooks, put_flash, and Gettext continue to work.
I also tried to reuse existing tools instead of reinventing everything. For example, icons use existing icon collections, notifications build on Phoenix flash, and translations use Gettext rather than introducing another translation system.
Getting started
There’s an installer for new Phoenix applications:
mix phx.new my_app
cd my_app
# Add {:xenia, "~> 0.1.0"} to mix.exs
mix deps.get
mix xenia.install
I’ve also included a runnable examples application with pages demonstrating the different features, along with documentation for writing your own adapters.
Links
GitHub:
Documentation: Xenia — Xenia v0.1.0
Hex: xenia | Hex
Examples: xenia/examples at main · uzaydurdu/xenia · GitHub
Xenia is completely free and MIT-licensed.
I’d really appreciate your feedback!
This is my first release, and I’d genuinely love to know what other Phoenix developers think.
I’m open to any criticism, suggestions, or feedback, so please don’t hesitate to share your thoughts!
Especially if you think something is unnecessarily complicated, could be designed differently, doesn’t follow Phoenix conventions well enough, or is simply not something you’d want in your own application. I’d much rather hear that than only positive comments.
And if there’s a JavaScript library you’ve had trouble integrating with LiveView, I’d be interested to see how Xenia handles it.
I’m not trying to replace Phoenix or build another frontend framework. I really enjoy working with LiveView, and this is my attempt to make using the JavaScript ecosystem alongside it a little easier.
Thanks for taking a look! ![]()
Trending in Announcing
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
- #umbrella
- #full-time-contract
- #elixirconf-us
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #elixirconf-eu
- #processes
- #security
- #api
- #forms
- #performance











Showing Posts 1 to 2- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
mcomak
Tried this out and really liked the adapter approach. Having a reusable way to handle prop updates, events, and cleanup makes integrating JS libraries with LiveView feel much cleaner. I also appreciate that it builds on Phoenix’s existing conventions. The form integration and persistent components look particularly useful. Nice work, and thanks for sharing!
uzaydurdu
Thanks a lot for your time. It is good to hear that form integration had worked for someone