コンテンツにスキップ
Tauri

ディープリンク

Tauri アプリケーションを URL のデフォルトハンドラとして設定します。

This plugin requires a Rust version of at least 1.77.2

Platform Level Notes
windows
linux
macos

Deep links must be registered in config. Dynamic registration at runtime is not supported.

android

Deep links must be registered in config. Dynamic registration at runtime is not supported.

ios

Deep links must be registered in config. Dynamic registration at runtime is not supported.

ディープリンクプラグインをインストールして開始します。

プロジェクトのパッケージマネージャーを使用して依存関係を追加します。

npm run tauri add deep-link

Android でリンクからアプリを開く方法は 2 つあります。

  1. アプリリンク (http/https + ホスト、検証済み) アプリリンク の場合、所定の形式でテキスト応答を返す .well-known/assetlinks.json エンドポイントを持つサーバーが必要です。
.well-known/assetlinks.json
[
{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "$APP_BUNDLE_ID",
"sha256_cert_fingerprints": [
$CERT_FINGERPRINT
]
}
}
]

ここで、$APP_BUNDLE_IDtauri.conf.json > identifier で定義された値で -_ に置き換えたものであり、 $CERT_FINGERPRINT はアプリの署名証明書の SHA256 フィンガープリントのリストです。 詳細については、Android アプリリンクの検証 を参照してください。

  1. カスタム URI スキーム (ホスト不要、検証なし) myapp://... のような URI の場合、ファイルをホストせずにカスタムスキームを宣言できます。モバイル設定で scheme フィールドを使用し、host を省略します。

iOS でリンクからアプリを開く方法は 2 つあります。

  1. ユニバーサルリンク (https + ホスト、検証済み) ユニバーサルリンク の場合、所定の形式で JSON 応答を返す .well-known/apple-app-site-association エンドポイントを持つサーバーが必要です。
.well-known/apple-app-site-association
{
"applinks": {
"details": [
{
"appIDs": ["$DEVELOPMENT_TEAM_ID.$APP_BUNDLE_ID"],
"components": [
{
"/": "/open/*",
"comment": "Matches any URL whose path starts with /open/"
}
]
}
]
}
}

ここで、$DEVELOPMENT_TEAM_IDtauri.conf.json > tauri > bundle > iOS > developmentTeam または TAURI_APPLE_DEVELOPMENT_TEAM 環境変数で定義された値であり、$APP_BUNDLE_IDtauri.conf.json > identifier で定義された値です。

ドメインがアプリの関連付けを公開するように適切に設定されているかを確認するには、次のコマンドを実行します(<host> を実際のホストに置き換えてください)。

Terminal window
curl -v https://app-site-association.cdn-apple.com/a/v1/<host>

詳細については、applinks.details を参照してください。

  1. カスタム URI スキーム (ホスト不要、検証なし) myapp://... のような URI の場合、"appLink": false でモバイル設定の下にカスタムスキームを宣言できます(または省略します)。プラグインはアプリの Info.plist に適切な CFBundleURLTypes エントリを生成します。.well-known ファイルや HTTPS ホストは必要ありません。

Linux と Windows では、ディープリンクは新しいアプリプロセスのコマンドライン引数として配信されます。 ディープリンクプラグインは、イベントを受信する単一のアプリインスタンスを持つことを好む場合、single instance プラグインと統合されています。

  • まず、deep-link 機能を single instance プラグインに追加する必要があります。
src-tauri/Cargo.toml
[target."cfg(any(target_os = \"macos\", windows, target_os = \"linux\"))".dependencies]
tauri-plugin-single-instance = { version = "2.0.0", features = ["deep-link"] }
  • 次に、常に登録する最初のプラグインである必要がある single instance プラグインを設定します。
src-tauri/lib.rs
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
let mut builder = tauri::Builder::default();
#[cfg(desktop)]
{
builder = builder.plugin(tauri_plugin_single_instance::init(|_app, argv, _cwd| {
println!("a new app instance was opened with {argv:?} and the deep link event was already triggered");
// ランタイムにディープリンクスキームを定義する場合、ここで `argv` も確認する必要があります
}));
}
builder = builder.plugin(tauri_plugin_deep_link::init());
}

tauri.conf.json > plugins > deep-link で、アプリケーションに関連付けるモバイルドメイン/スキームとデスクトップスキームを設定します。

モバイルのカスタムスキーム (サーバー不要):

tauri.conf.json
{
"plugins": {
"deep-link": {
"mobile": [
{
"scheme": ["ovi"],
"appLink": false
}
]
}
}
}

これにより、Android と iOS で ovi://* スキームが登録されます。

アプリリンク / ユニバーサルリンク (検証済み https + ホスト):

{
"plugins": {
"deep-link": {
"mobile": [
{
"scheme": ["https"],
"host": "your.website.com",
"pathPrefix": ["/open"],
"appLink": true
}
]
}
}
}

これにより、https://your.website.com/open/* がアプリ/ユニバーサルリンクとして登録されます。

デスクトップカスタムスキーム:

{
"plugins": {
"deep-link": {
"desktop": {
"schemes": ["something", "my-tauri-app"]
}
}
}
}

ディープリンクプラグインは、JavaScript と Rust の両方で使用できます。

アプリの実行中にディープリンクがトリガーされると、onOpenUrl コールバックが呼び出されます。アプリがディープリンク経由で開かれたかどうかを検出するには、アプリの起動時に getCurrent を使用します。

import { getCurrent, onOpenUrl } from '@tauri-apps/plugin-deep-link';
// `"withGlobalTauri": true` を使用する場合、以下を使用できます
// const { getCurrent, onOpenUrl } = window.__TAURI__.deepLink;
const startUrls = await getCurrent();
if (startUrls) {
// アプリはおそらくディープリンク経由で起動されました
// getCurrent の戻り値は、onOpenUrl がトリガーされるたびに更新されることにも注意してください。
}
await onOpenUrl((urls) => {
console.log('deep link:', urls);
});

設定 セクションでは、アプリケーションの静的ディープリンクスキームを定義する方法について説明しています。

Linux と Windows では、register Rust 関数を介してランタイムにアプリケーションにスキームを関連付けることも可能です。

次のスニペットでは、ランタイムに my-app スキームを登録します。アプリを初めて実行した後、オペレーティングシステムは my-app://* URL をアプリケーションで開きます。

src-tauri/src/lib.rs
use tauri_plugin_deep_link::DeepLinkExt;
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_deep_link::init())
.setup(|app| {
#[cfg(desktop)]
app.deep_link().register("my-app")?;
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

アプリケーションのディープリンクをテストするには、いくつかの注意点があります。

ディープリンクは、デスクトップにインストールされたアプリケーションに対してのみトリガーされます。 Linux と Windows では、register_all Rust 関数を使用してこれを回避できます。これは、構成されたすべてのスキームを登録して現在の実行可能ファイルをトリガーします。

src-tauri/src/lib.rs
use tauri_plugin_deep_link::DeepLinkExt;
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_deep_link::init())
.setup(|app| {
#[cfg(any(windows, target_os = "linux"))]
{
use tauri_plugin_deep_link::DeepLinkExt;
app.deep_link().register_all()?;
}
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

Windows でディープリンクをトリガーするには、ブラウザで <scheme>://url を開くか、ターミナルで次のコマンドを実行します。

Terminal window
start <scheme>://url

Linux でディープリンクをトリガーするには、ブラウザで <scheme>://url を開くか、ターミナルで xdg-open を実行します。

Terminal window
xdg-open <scheme>://url

iOS でアプリリンクをトリガーするには、ブラウザで https://<host>/path URL を開くことができます。シミュレーターの場合、simctl CLI を利用してターミナルからリンクを直接開くことができます。

Terminal window
xcrun simctl openurl booted https://<host>/path

Android でアプリリンクをトリガーするには、ブラウザで https://<host>/path URL を開くことができます。エミュレーターの場合、adb CLI を利用してターミナルからリンクを直接開くことができます。

Terminal window
adb shell am start -a android.intent.action.VIEW -d https://<host>/path <bundle-identifier>

デフォルトでは、すべての潜在的に危険なプラグインコマンドとスコープはブロックされており、アクセスできません。これらを有効にするには、capabilities 設定の権限を変更する必要があります。

詳細については、機能の概要 と、プラグイン権限を使用するための ステップバイステップガイド を参照してください。

src-tauri/capabilities/default.json
{
"$schema": "../gen/schemas/mobile-schema.json",
"identifier": "mobile-capability",
"windows": ["main"],
"platforms": ["iOS", "android"],
"permissions": [
// 通常、ディープリンクイベントをリッスンするには core:event:default が必要です
"core:event:default",
"deep-link:default"
]
}

Default Permission

Allows reading the opened deep link via the get_current command

This default permission set includes the following:

  • allow-get-current

Permission Table

Identifier Description

deep-link:allow-get-current

Enables the get_current command without any pre-configured scope.

deep-link:deny-get-current

Denies the get_current command without any pre-configured scope.

deep-link:allow-is-registered

Enables the is_registered command without any pre-configured scope.

deep-link:deny-is-registered

Denies the is_registered command without any pre-configured scope.

deep-link:allow-register

Enables the register command without any pre-configured scope.

deep-link:deny-register

Denies the register command without any pre-configured scope.

deep-link:allow-unregister

Enables the unregister command without any pre-configured scope.

deep-link:deny-unregister

Denies the unregister command without any pre-configured scope.


© 2025 Tauri Contributors. CC-BY / MIT