tauri-plugin-openurl

Crates.iotauri-plugin-openurl
lib.rstauri-plugin-openurl
version0.1.0
sourcesrc
created_at2024-04-08 15:51:28.331877
updated_at2024-10-08 16:36:20.270059
descriptionopen url in default browser (just like target blank) in Tauri
homepage
repository
max_upload_size
id1200489
size55,965
Priyadarshan Giri (giripriyadarshan)

documentation

README

Crates.io Version Crates.io Total Downloads NPM Version NPM Downloads

Tauri Plugin openurl

Open url in browser on all platforms1 (excluding IOS, still in testing). Basically <a target="_blank"></a> replacement for all platforms1.

Usage

This plugin is still part of Tauri V2 Beta. So, this project might be replaced by a fix in Tauri core itself before project is stable.

Setup

npm

npm i tauri-plugin-openurl-api

&& cargo (possibly inside ./src-tauri/)

cargo add tauri-plugin-openurl

also add this to your tauri builder

tauri::Builder::default()
    // other plugins
    .plugin(tauri_plugin_openurl::init())
    // rest of the builder

Usage

import { open_url } from "tauri-plugin-openurl-api";

<button onClick={() => {
    open_url("https://crates.io/crates/tauri-plugin-openurl");
}}>Click to open in default browser</button>

Permissions

Please make sure you add this permission to all platforms you intend to use in

{
  "permissions": [
    "openurl:allow-open-url"
  ]
}

References:

1 : excluding IOS as it is still in testing.

Commit count: 0

cargo fmt