> ## Documentation Index
> Fetch the complete documentation index at: https://crosslink.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Tauri Integration

> Using Crosslink in Tauri applications

## Setup

```bash theme={null}
# Frontend (Rust side is not needed for Crosslink)
npm install @crosslink/sdk-browser
```

## Frontend (Rust)

Tauri apps use the browser SDK in the webview:

```js theme={null}
import { CrosslinkClient } from "@crosslink/sdk-browser";

const client = await CrosslinkClient.create({
  deviceName: "Tauri App",
  onStateChange: (state) => console.log("State:", state)
});
```

## Rust backend (optional)

If you need to expose Crosslink functionality from the Rust backend:

```rust theme={null}
// src-tauri/src/main.rs
use tauri::Manager;

#[tauri::command]
async fn get_pairing_code(app: tauri::AppHandle) -> Result<String, String> {
    // Call the Node.js process or implement Crosslink in Rust
    todo!()
}

fn main() {
    tauri::Builder::default()
        .invoke_handler(tauri::generate_handler![get_pairing_code])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}
```

## IPC bridge

Use Tauri's event system to communicate between frontend and backend:

```js theme={null}
import { emit, listen } from "@tauri-apps/api/event";

// Listen for pairing events
listen("crosslink:pairing-code", (event) => {
  console.log("Pairing code:", event.payload);
});

// Emit pairing approval
emit("crosslink:approve-pairing", { approved: true });
```

## Permissions

Tauri's permission system can work with Crosslink capabilities:

```json theme={null}
// tauri.conf.json
{
  "app": {
    "security": {
      "permissions": [
        "core:default",
        "crosslink:allow-pair",
        "crosslink:allow-call"
      ]
    }
  }
}
```

## Mobile support

Crosslink works on mobile Tauri apps (iOS/Android) via the browser SDK:

```js theme={null}
// Works on iOS and Android webviews
const client = await CrosslinkClient.create({
  deviceName: "Mobile App",
  // On mobile, WebCrypto is available in secure contexts
});
```

## Security notes

* The webview runs in a sandboxed environment
* Use Tauri's IPC for sensitive operations
* Store identity keys in the Rust backend (not webview storage)
* Consider using Tauri's secure storage for sensitive data

## Building

```bash theme={null}
# Build for current platform
npm run tauri build

# Build for mobile
npm run tauri ios build
npm run tauri android build
```
