tauri-apps / tauri-apps/plugins-workspace

[feat] platform utility functions per plugin package

Open
#1,365 0 comments 0 reactions 0 assignees View on GitHub
type: feature request
Dominant language
Rust
Stars
1.8k
Forks
602
Avg merge
4d 14h
Merged PRs (30d)
9

Description

As a developer I would like to have a utility function to see if the plugin is supported by the platform.
So I can conditionally show my UI or write other logic, while writing an multiplatform app.

Adding a utility like this will help me because:
- It saves time (dont have to go to the docs of the plugin)
- Is less error prone

Currently I have do to something like this to conditionally show a button that triggers the barcode scan button:
```tsx
import { platform } from '@tauri-apps/plugin-os';
import { scan, Format } from '@tauri-apps/plugin-barcode-scanner';

function scanBarcode() {
return scan({ windowed: true, formats: [Format.QRCode] });
}

const isSupported = Boolean(platform === "ios" || platform === "andriod")

export function App() {
return (


{isSupported && Scan}

):
}
```

Proposal:

```tsx
import { scan, Format, isSupported } from '@tauri-apps/plugin-barcode-scanner';

function scanBarcode() {
return scan({ windowed: true, formats: [Format.QRCode] });
}

export function App() {
return (


{isSupported && Scan}

):
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.