tonydang

tonydang

Hi everyone! I’m new to the forums and new to Elixir in general. To learn Elixir, I recently just completed my first app. It’s a todo app built with Phoenix LiveView, but with a twist, it can also work offline :smirk:

By using the LiveSvelte package, I was able to use LiveView to render Svelte components which allows for offline-support. I know an offline app was not what LiveView was intended for, but I thought it was neat that it was possible to still use LiveView in such an app.

I haven’t gotten the chance to dive deeper into Phoenix Channels yet so I’m not sure if the app would perform better just using that instead. However, so far the app has been working well for me and the DX of using LiveView has been great. Anyhow, I thought I would share in case anyone else is interested in building offline-enabled apps with LiveView :slight_smile:

Here’s a video I made walking through how I made the app:

Source code:

Live Demo:

Any questions and feedback welcomed!

Showing Posts 1 to 10

arcanemachine

arcanemachine

Very cool. I tried it out and it works as promised.

Would you mind putting a license on the repo so that I know what I’m allowed to do with the code?

tonydang

tonydang OP

Thanks for checking out the app!

And yes, I just added an MIT license. Please feel free to use the code as you please :slight_smile:

11
Post #2
hellosmithy

hellosmithy

Very cool to see a CRDT example with Elixir. This was on my bucket list of things to try out. Thanks for sharing.

phi

phi

Awesome work. Would you mind adding a .env.example for us newbies?

tonydang

tonydang OP

Absolutely, I just added a .env.example to the repo:
https://github.com/tonydangblog/liveview-svelte-pwa/blob/main/.env.example

I included some comments in the file for more explanation, but in short, it holds the two variables:

  • JS_BACKEND_URL - The server I’m using to 1. run Yjs server-side, and 2. send emails via Cloudflare Workers.
  • JWT_PRIVATE_KEY - Private key used to sign JWTs needed when sending requests to the JS backend server.

Please see the comments in the file for more info and feel free to let me know if you have any questions!

phi

phi

Cheers! Will try to get the Yjs backend setup myself, hopefully no issues.

nico_amsterdam

nico_amsterdam

Very good explanation of the offline enabled app and it’s concepts.

tonydang

tonydang OP

Hi all! I wanted to give an update on this project-

In my video, I discussed using Yjs on the server-side in order to merge the states of the various clients. This worked, but was not ideal since it required running JS from Phoenix or from a separate JS backend server (which is what I did for my project via a Cloudflare Worker).

Since then, I have found out that it is not necessary at all to run Yjs on the server in order to sync the clients. I have updated my repo to no longer need a separate JS backend. I also made a video explaining how it is possible to do so. You can check it out here if interested:

mindreframer

mindreframer

Thanks! That’s quite interesting, but it is clearly problematic for any real-life cases with non-trivial amount of data. I think our best bet as community would be to create a Rustler wrapper package around yrs - Rust to be able to reconcile state diffs (patches). That way we could use it for realistic data amounts and keep the chattiness of the network traffic at bay.

But yeah, someone with Rust skills would have to create the wrapper first :slight_smile:

Maybe we’ll have a production quality CRDT bindings in near future.
Cheers!

tonydang

tonydang OP

I definitely agree that sending the entire app state every time is not scalable and a Rustler wrapper would be awesome!

One other idea I had that may also work is: Instead of sending the entire app state every time, we could just send Yjs updates for each change. And, on the server, instead of keeping a single app state, we can keep a table of all updates sent. Then, when a client reconnects, it can request all the updates it has missed. I haven’t tried this out, but I think that it should work in theory.

Definitely still not as good as just having a Yjs port, but just thinking out loud :slight_smile:

Where Next? Top

Trending in Discussions Top

cblavier
Hey there, It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
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
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
axelson
Hi there! :wave: @frigidcode and I (but mostly him) have been running an Elixir Book club, we’re almost done with Designing Elixir Syste...
New
achempion
I’ve been using Emacs as my main code editor for more than a two years. It’s a custom build version although I’ve tried doom emacs and sp...
New
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New

Other Trending Topics Top

HR_Sportograf
Backend Developer for Elixir (F/M/D) - Shape the Future of Sports Photography with Us!(German Version below) About us We are athletes –...
New
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
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
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
georgeguimaraes
Just published claude-code-elixir, a plugin marketplace for Claude Code with Elixir support. These are the plugins I’ve been using for my...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews