| Crates.io | tauri-plugin-deno |
| lib.rs | tauri-plugin-deno |
| version | 0.2.0 |
| created_at | 2025-02-28 15:54:50.861482+00 |
| updated_at | 2025-03-16 20:21:16.117129+00 |
| description | A tauri 2 plugin to use javascript code (deno) in the backend. |
| homepage | https://github.com/marcomq/tauri-plugin-deno |
| repository | https://github.com/marcomq/tauri-plugin-deno |
| max_upload_size | |
| id | 1572945 |
| size | 304,469 |
This tauri v2 plugin is supposed to make it easy to use Javascript as backend code. It uses Deno as runtime.
A single deno thread is started in the background and uses tokio to call javascript functions asynchronously. Channels are used to exchange data between tauri and deno runtime. By default, the file src-tauri/src-deno/main.ts is executed on startup. If you want to use typescript, please use some packager to transpile
your typescript into main.js first - for example by using rollup.
This plugin is not yet in production state. It might still have some issues. I currently only tested it on MacOS and did not optimize it yet for release builds. There might be changes later, for example to auto include backend javascript.
Planned changes:
npm run tauri add denosrc-tauri/src-deno/main.js and modify it according to your needs, for example add# src-tauri/src-deno/main.ts
function greetJs(input) {
return str(input) + " from main.js"
}
addTauri(greetJs); // This will make the function "greetJs" callable from UI
"bundle": {"resources": [ "src-deno/**/*"], to tauri.conf.json so that javascript files are bundled with your applicationimport { callFunction } from 'tauri-plugin-deno-api'window.document.body.innerText = await callFunction("greetJs", [value]) to get the output of the backend javascript function greetJs with parameter of js variable valuewindow.document.body.innerText = window.__TAURI__.deno.callFunction("greetJs", [value.value]) directly, if you want to use old style javascript without using importsThis is just an example of how to modify client side content. You may just set some value or a local variable.
This plugin has been created with security in mind.
No network server or client is started by this plugin.
By default, this plugin cannot call javascript backend code. Backend functions can only be called if registered, for example by using the addTauri(fn) function in the backend javascript code. This will make the backend function fn available in to UI.
There are following additional permissions available that can be added to by using the permissions file tauri-app/src-tauri/capabilities/default.json:
callFunction; calls function in backend; enabled by default)readVariable; read variable from backend)registerFunction; client side way of allowing additional functions)runCode; call code directly in backend)