Handle Deep Link (myapp://)
Register the scheme
Section titled “Register the scheme”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.
Handle URLs
Section titled “Handle URLs”Install the required plugin:
tynd add single-instanceimport { 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.
Validate aggressively
Section titled “Validate aggressively”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.