Socket
Book a DemoInstallSign in
Socket

tauri-plugin-in-app-browser-api

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tauri-plugin-in-app-browser-api

> [!CAUTION] > This was a plugin primarily made for myself. I've made it open-source so that other people could use it, but I'm not willing to document everything. If you do need some help / clarification / changes, you can contact me on Discord / Twitter

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
5
25%
Maintainers
1
Weekly downloads
 
Created
Source

Tauri Plugin in_app_browser

[!CAUTION] This was a plugin primarily made for myself. I've made it open-source so that other people could use it, but I'm not willing to document everything. If you do need some help / clarification / changes, you can contact me on Discord / Twitter: manaf941 / manaaaaaaaf

Usage

src-tauri/src/lib.rs

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
    tauri::Builder::default()
        // this line initializes the plugin
        .plugin(tauri_plugin_in_app_browser::init())
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

src-tauri/capabilities/default.json

{
    "permissions": [
        "in-app-browser:default",
        "in-app-browser:allow-open-safari",
        "in-app-browser:allow-close-safari",
        "in-app-browser:allow-open-chrome"
    ]
}

index.ts

import { open_safari, open_chrome } from 'tauri-plugin-in-app-browser-api'

// iOS
const browser = await open_safari({
    // See guest-js/index.ts for available options
    url: "https://google.com",

    // Color should be in rgba format, such as `#rrggbbaa`
    preferredControlTintColor: "#ff0000ff"
})

browser.addEventListener("close", () => {
    // browser closed (either by the user or by browser.close())
})

// after some time, force the user to close safari
await browser.close()

// Android
await open_chrome({
    // See guest-js/index.ts for available options
    url: "https://google.com"
})

[!WARNING] On iOS, if you set modalPresentationStyle to fullScreen, your application might get paused. Any timeout to browser.call won't be ran.

Design Choices

  • I've chosen to not make platform-agnostic code to have full control over desired styling and behavior.
  • I needed to use SFSafariViewController to use Apple Pay through a dynamic merchant (Not available through PassKit). As such, I did not implement WKWebView. You can probably already do this with Tauri already though
  • Unfortunately, Android doesn't allow closing a Chrome Custom Tabs. As such, there's no browser.close feature. You can't even know if a tab has been closed. You should use Activities and Deep Linking to know if a tab has been closed. If it is that much critical to your process, you should probably use an iframe or a webview.

Contact

In case of questions, contact me on my socials: Discord: @manaf941 Twitter: manaaaaaaaf

FAQs

Package last updated on 21 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts