Tauri Core API - v2.6.0
    Preparing search index...

    Interface WebviewOptions

    Configuration for the webview to create.

    2.0.0

    interface WebviewOptions {
        url?: string;
        x: number;
        y: number;
        width: number;
        height: number;
        transparent?: boolean;
        focus?: boolean;
        dragDropEnabled?: boolean;
        acceptFirstMouse?: boolean;
        userAgent?: string;
        incognito?: boolean;
        proxyUrl?: string;
        zoomHotkeysEnabled?: boolean;
        useHttpsScheme?: boolean;
        devtools?: boolean;
        backgroundColor?: webview.Color;
        backgroundThrottling?: BackgroundThrottlingPolicy;
        javascriptDisabled?: boolean;
        allowLinkPreview?: boolean;
        disableInputAccessoryView?: boolean;
    }
    Index

    Properties

    url?: string

    Remote URL or local file path to open.

    • URL such as https://github.com/tauri-apps is opened directly on a Tauri webview.
    • data: URL such as data:text/html,<html>... is only supported with the webview-data-url Cargo feature for the tauri dependency.
    • local file path or route such as /path/to/page.html or /users is appended to the application URL (the devServer URL on development, or tauri://localhost/ and https://tauri.localhost/ on production).
    x: number

    The initial vertical position.

    y: number

    The initial horizontal position.

    width: number

    The initial width.

    height: number

    The initial height.

    transparent?: boolean

    Whether the webview is transparent or not. Note that on macOS this requires the macos-private-api feature flag, enabled under tauri.conf.json > app > macOSPrivateApi. WARNING: Using private APIs on macOS prevents your application from being accepted to the App Store.

    focus?: boolean

    Whether the webview should have focus or not

    2.1.0

    dragDropEnabled?: boolean

    Whether the drag and drop is enabled or not on the webview. By default it is enabled.

    Disabling it is required to use HTML5 drag and drop on the frontend on Windows.

    acceptFirstMouse?: boolean

    Whether clicking an inactive webview also clicks through to the webview on macOS.

    userAgent?: string

    The user agent for the webview.

    incognito?: boolean

    Whether or not the webview should be launched in incognito mode.

    • Android: Unsupported.
    proxyUrl?: string

    The proxy URL for the WebView for all network requests.

    Must be either a http:// or a socks5:// URL.

    • macOS: Requires the macos-proxy feature flag and only compiles for macOS 14+.
    zoomHotkeysEnabled?: boolean

    Whether page zooming by hotkeys is enabled

    • Windows: Controls WebView2's IsZoomControlEnabled setting.

    • MacOS / Linux: Injects a polyfill that zooms in and out with ctrl/command + -/=, 20% in each step, ranging from 20% to 1000%. Requires webview:allow-set-webview-zoom permission

    • Android / iOS: Unsupported.

    useHttpsScheme?: boolean

    Sets whether the custom protocols should use https://<scheme>.localhost instead of the default http://<scheme>.localhost on Windows and Android. Defaults to false.

    Using a https scheme will NOT allow mixed content when trying to fetch http endpoints and therefore will not match the behavior of the <scheme>://localhost protocols used on macOS and Linux.

    Changing this value between releases will change the IndexedDB, cookies and localstorage location and your app will not be able to access them.

    2.1.0

    devtools?: boolean

    Whether web inspector, which is usually called browser devtools, is enabled or not. Enabled by default.

    This API works in debug builds, but requires devtools feature flag to enable it in release builds.

    • macOS: This will call private functions on macOS.
    • Android: Open chrome://inspect/#devices in Chrome to get the devtools window. Wry's WebView devtools API isn't supported on Android.
    • iOS: Open Safari > Develop > [Your Device Name] > [Your WebView] to get the devtools window.

    2.1.0

    backgroundColor?: webview.Color

    Set the window and webview background color.

    • macOS / iOS: Not implemented.
    • Windows:
      • On Windows 7, alpha channel is ignored.
      • On Windows 8 and newer, if alpha channel is not 0, it will be ignored.

    2.1.0

    backgroundThrottling?: BackgroundThrottlingPolicy

    Change the default background throttling behaviour.

    By default, browsers use a suspend policy that will throttle timers and even unload the whole tab (view) to free resources after roughly 5 minutes when a view became minimized or hidden. This will pause all tasks until the documents visibility state changes back from hidden to visible by bringing the view back to the foreground.

    • Linux / Windows / Android: Unsupported. Workarounds like a pending WebLock transaction might suffice.
    • iOS: Supported since version 17.0+.
    • macOS: Supported since version 14.0+.

    see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578

    2.3.0

    javascriptDisabled?: boolean

    Whether we should disable JavaScript code execution on the webview or not.

    allowLinkPreview?: boolean

    on macOS and iOS there is a link preview on long pressing links, this is enabled by default. see https://docs.rs/objc2-web-kit/latest/objc2_web_kit/struct.WKWebView.html#method.allowsLinkPreview

    disableInputAccessoryView?: boolean

    Allows disabling the input accessory view on iOS.

    The accessory view is the view that appears above the keyboard when a text input element is focused. It usually displays a view with "Done", "Next" buttons.