tauri-apps / tauri

Build smaller, faster, and more secure desktop applications with a web frontend.
https://tauri.app
Apache License 2.0
79.57k stars 2.36k forks source link

Use with OTP/Elixir, and specifically Phoenix LiveView #1270

Open mayel opened 3 years ago

mayel commented 3 years ago

Is your feature request related to a problem? Please describe.

Glad to see a solid alternative to Electron! While Rust is a great choice (though I am currently building apps in Elixir) I much prefer not using JS-heavy frameworks like React and instead use Phoenix's LiveView to build SPA apps driven by the backend.

Describe the solution you'd like

I'd love see what it would take to bundle OTP and an Elixir and LiveView-based app using Tauri.

Describe alternatives you've considered

Bakeware is a step in the right direction, and could maybe be combined with Tauri for these purposes.

tensor-programming commented 3 years ago

Hmm, it might be interesting to do this. Really, would just need to use bakeware or elixirscript and then sideload the pheonix/elixir binary with the Tauri app to produce a binary containing both. The main difference here between a live view style app and something more traditional, is that you have this server in between, feeding the rendered HTML into the Tauri WebView through the phoenix channel.

The other side of this is that you would likely have to use an embeddable database if you planned to still use ecto. You wouldn't be able to package postgres with the phoenix app.

mayel commented 3 years ago

Glad to hear it seems straightforward! I just saw embedding binaries is already supported, so I guess we'd mostly need a third app loading mode to load the Elixir app's port.

[off topic @tensor-programming you may be interested in this if you haven't seen t yet]

lucasfernog commented 3 years ago

We should probably work to make this possible with a Tauri plugin.

nklayman commented 3 years ago

Here is an example of a Tauri app that spawns a binary that starts a server and then navigates the webview to that url.

Laegel commented 3 years ago

You should also consider looking for an embeddable database to replace Postgres for your project: good news, we have an SQLite plugin!

mayel commented 3 years ago

The other side of this is that you would likely have to use an embeddable database if you planned to still use ecto. You wouldn't be able to package postgres with the phoenix app.

Yeah that was at the back of my mind... Postgres can do silent installs on Windows, and there's an app bundle for OSX (and Linux users are used to and usually know how to jump through a few more hoops) but I guess users would have to set that up separately?

mayel commented 3 years ago

You should also consider looking for an embeddable database to replace Postgres for your project: good news, we have an SQLite plugin!

While that may suit a lot of projects, some apps use things like JSONB fields, Postgis, or other features that would at the very least require rewrites and at worst loose important functionality (not to mention performance).

tensor-programming commented 3 years ago

@mayel yeah, am aware of Nx. Yet another really cool idea out of the elixir scene.

I am looking at building a LiveView example right now just to see whats possible and where the potential bottle necks are. And I wonder what kind of benefits you would get from this kind of setup.

mayel commented 3 years ago

@tensor-programming no pressure, but wondering what you discovered if you got around to playing with this?

jonericcook commented 2 years ago

+1 on being excited about the possibility of running a phoenix app on a desktop and mobile 🤞

@tensor-programming here are some projects doing somewhat similar things

And any news on this?

jonericcook commented 2 years ago

another cool project that could be useful? https://github.com/burrito-elixir/burrito

gotjoshua commented 2 years ago

very curious to see examples of tauri apps with elixir!

nothingismagick commented 2 years ago

One of the (only?) concerns with rustler Nifs is that you won't be able to handle extreme crashes...

https://news.ycombinator.com/item?id=31023587

nothingismagick commented 2 years ago

A neat use case for this would be to ship an elixir binary as a sidecar and use phoenix channels and websocket listeners in the webview (or just place liveviews in the webview too). I would expect this to literally work right out of the box.

heri16 commented 2 years ago

No to Typescript. Prefer just Liveview but doesn't seem to be a way to call Taurus API from Liveview?

nothingismagick commented 2 years ago

Liveview is really AFAIK SSR HTML passed to Tauri via websockets. So you HAVE to place the liveview into the webview somehow and that means integrating a websocket.

image
nothingismagick commented 2 years ago

But we haven't experimented with how you would interact with the API in this way, but it is interesting for sure.

feng19 commented 1 year ago

I make a demo project for this lookup here: https://github.com/feng19/phx_new_desktop

chris838 commented 5 months ago

@feng19 thanks for sharing, this repo is super helpful!

I notice you're calling out to rust/tauri from within javascript (i.e. client-side, if this was a web app). Is it possible to interface with tauri from within Elixir? There is a rust API as well as JS, so not sure if this is possible from within a Rust NIF in Elixir.

feng19 commented 5 months ago

@feng19 thanks for sharing, this repo is super helpful!

I notice you're calling out to rust/tauri from within javascript (i.e. client-side, if this was a web app). Is it possible to interface with tauri from within Elixir? There is a rust API as well as JS, so not sure if this is possible from within a Rust NIF in Elixir.

Erlang VM and Tauri are separate processes, there is no ready-made interface, maybe you can have a try.

Exadra37 commented 2 months ago

I am working in this fork to improve ex_tauri from @filipecabaco , but the most challenging part is not being able to cross compile from Linux to other platfroms, and not be able to use Tauri actions to compile an actual release that works on Linux, but I can compile on locally that runs fine :). Eventually some day I will manage to get this to work ;)