Skip to content

Handle Deep Link (myapp://)

tynd.config.ts
export default {
backend: "backend/main.ts",
frontendDir: "dist",
protocols: ["myapp"],
bundle: { identifier: "com.example.myapp" },
} satisfies TyndConfig;

tynd build wires the scheme into the NSIS / MSI / .app / .deb / .rpm / .AppImage installer.

Install the required plugin:

Terminal window
tynd add single-instance
import { app } from "@tynd/core/client";
import { singleInstance } from "@tynd/plugin-single-instance/client";
const { acquired } = await singleInstance.acquire("com.example.myapp");
if (!acquired) await app.exit(0); // primary has already been focused + notified
singleInstance.onOpenUrl((url) => {
const parsed = new URL(url);
// url = "myapp://invite/abc123?ref=twitter"
// parsed.hostname === "invite"
// parsed.pathname === "/abc123"
// parsed.searchParams.get("ref") === "twitter"
handleDeepLink(parsed);
});

onOpenUrl fires for:

  • Cold start — the argv carries the URL.
  • Duplicate launch — the primary receives the forwarded URL.

Treat deep-link input as untrusted. Validate against a whitelist before acting:

function handleDeepLink(url: URL) {
if (url.hostname === "invite" && /^\/[a-z0-9]+$/i.test(url.pathname)) {
router.navigate(url.pathname);
} else {
console.warn("ignored unknown deep link", url.href);
}
}

Related: Deep Linking guide · singleInstance API.