Function tauri::api::shell::open

source ·
pub fn open<P: AsRef<str>>(
    scope: &ShellScope,
    path: P,
    with: Option<Program>
) -> Result<()>
Available on crate feature shell-open-api only.
Expand description

Opens path or URL with the program specified in with, or system default if None.

The path will be matched against the shell open validation regex, defaulting to ^((mailto:\w+)|(tel:\w+)|(https?://\w+)).+. A custom validation regex may be supplied in the config in tauri > allowlist > scope > open.

§Examples

use tauri::{api::shell::open, Manager};
tauri::Builder::default()
  .setup(|app| {
    // open the given URL on the system default browser
    open(&app.shell_scope(), "https://github.com/tauri-apps/tauri", None)?;
    Ok(())
  });