uzaydurdu

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.ex and layout.ex files 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.install to 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! :slightly_smiling_face:

Showing Posts 1 to 2

mcomak

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

uzaydurdu OP

Thanks a lot for your time. It is good to hear that form integration had worked for someone :slight_smile:

— All posts loaded —

Where Next? Top

Trending in Announcing Top

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
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
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
danschultzer
I’ve moved the strategies out of PowAssent and created a multi-provider framework for Elixir. This way the strategies can be used in any ...
New
gtcode
Aloha gang, There’s a new class of AI model out from TypeSafe. Jev is their flagship model. You can learn about it here: ...
New
danschultzer
I needed something like premailer for rails, and after searching, I decided to make an easy-to-use library to handle inline styles and co...
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
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
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
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
AstonJ
With advancements in AI gathering pace and set to increasingly accelerate, perhaps it’s worth having an annual thread on the topic - feel...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews