DEV Community

Cover image for Cross-Platform application with Ruby + Tauri
Joseph Schito
Joseph Schito

Posted on

2

Cross-Platform application with Ruby + Tauri

Is there any way to create a cross-platform client application that consumes a fraction of resources than Electron would use... with Ruby? 🀯

TLDR;
yes, this is the way πŸ‘‡

  1. Run sh <(curl https://create.tauri.app/sh)

  2. Set:

    • Project name: your-project (what you want)
    • Choose which language to use for your frontend: "TypeScript / JavaScript"
    • Choose your package manager: npm (what you want)
    • Choose your UI template: Vanilla
    • Choose your UI flavor: JavaScript Tauri setup
  3. Run:

    • gem install opal
    • cd your-project
    • echo "puts 'Hello from Opal!'" | cat > src/main.rb
    • open src/index.html file and move <script type="module" src="/main.js" defer></script> line to the bottom
    • mkdir src/app
    • npm install
    • npm run tauri dev
  4. Edit src-tauri/tauri.conf.json:

    • set beforeDevCommand with "opal --output=src/main.js --watch -c src/main.rb -I src/app"
    • set beforeBuildCommand with "opal -c src/main.rb --output=src/main.js --no-source-map -I src/app" Tauri configuration
  5. Go to the window console (https://tauri.app/v1/guides/debugging/application/#webview-console),
    you should see Hello from Opal! πŸ₯³
    Tauri application

Amazing uh? But... what next?

  • Add any .rb file in src/app and require it from src/main.rb, yeah that's it!
  • Build it with npm run tauri build

Build Space
Build ram

~6MB Space (notice that I didn't minify or optimize anything...)
~20-30MB Ram (this is crazy)

Joseph πŸ˜‰

Resources:
Opal guides
Tauri guides

Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Google’s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More

Top comments (0)

Image of Docusign

πŸ› οΈ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more