tauri/docs/usage/patterns/bridge.md

2.5 KiB

title
Bridge

import Rater from '@theme/Rater' import useBaseUrl from '@docusaurus/useBaseUrl'

Ease of Use
Extensibility
Performance
Security
Bridge
Pros:
  • Highly configurable
  • No Rust skills required
Cons:
  • Some WebAPIs unavailable
  • Challenge to implement

Description

The Bridge recipe is a secure pattern where messages are passed between brokers via an implicit bridge using the API. It isolates functionality to scope and passes messages instead of functionality.

Diagram

import Mermaid, { colors } from '@theme/Mermaid'

<Mermaid chart={graph TD H==>F subgraph WEBVIEW F-.-E end D-->E E-->D B-->D D-->B subgraph RUST A==>H A-->B B-.-C B-.-G end A[Binary] B{Rust Broker} C[Subprocess 2] G[Subprocess 1] D(( API BRIDGE )) E{JS Broker} F[Window] H{Bootstrap} style D fill:#ccc,stroke:#333,stroke-width:4px,color:white style RUST fill:${colors.orange.light},stroke:${colors.orange.dark},stroke-width:4px style WEBVIEW fill:${colors.blue.light},stroke:${colors.blue.dark},stroke-width:4px} />

Configuration

Here's what you need to add to your tauri.conf.json file:

"tauri": {
  "allowlist": {                  // all API values are default false
    "all": false,                 // use this flag to enable all API features
    "shell": {
      "execute": false,             // enable application execution
      "open": false,                // open link/path in the default app
    },
    "fs": {
      "listFiles": false,           // list files in a directory
      "readBinaryFile": false,      // read binary file from local filesystem
      "readTextFile": false,        // read text file from local filesystem
      "setTitle": false,            // set the window title
      "writeFile": false            // write file to local filesystem
    }
  }
}