#tauri #secure #http-request #invoke #localhost #http-server #system

tauri-invoke-http

Make tiny, secure apps for all desktop platforms with Tauri

3 releases (1 unstable)

2.0.0-rc.1 Sep 23, 2024
2.0.0-rc.0 Sep 17, 2024
0.1.0 Sep 16, 2024

#517 in GUI

Download history 210/week @ 2024-09-12 165/week @ 2024-09-19 73/week @ 2024-09-26 22/week @ 2024-10-03

470 downloads per month

Apache-2.0 OR MIT

19KB
456 lines

Tauri Invoke HTTP

This is a crate that provides a custom invoke system for Tauri using a localhost server. Each message is delivered through a XMLHttpRequest and the server is responsible for replying to it.

Usage

First, add the dependency to your src-tauri/Cargo.toml file:

[dependencies]
tauri-invoke-http = "0.1"

Then, setup the HTTP invoke system on the main.rs file:

fn main() {
  // initialize the custom invoke system as a HTTP server, allowing the given origins to access it.
  let http = tauri_invoke_http::Invoke::new(if cfg!(feature = "custom-protocol") {
    ["tauri://localhost"]
  } else {
    ["http://localhost:8080"]
  });
  tauri::Builder::default()
    .invoke_system(http.initialization_script())
    .setup(move |app| {
      http.start(app.handle());
      Ok(())
    })
    .run(tauri::generate_context!())
    .expect("error while running tauri application")
}

See examples/vanilla to see the custom invoke system in practice.

Dependencies

~18–58MB
~1M SLoC