Electron Desktop App Development · Lektion

Deep Linking und Protokoll-Handler

Ermöglichen Sie es Nutzern, Ihre Electron-App über benutzerdefinierte URL-Schemata zu starten und zu navigieren – eine wichtige Lifecycle-Integration, die Startup-Ereignisse und Updates ergänzt.

Lektion 4 von 413 Schritte

Deep Linking und Protokoll-Handler ist eine kostenlose Electron Desktop App Development-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Electron Desktop App Development-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Electron Desktop App Development-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

Launching From a Link

Deep linking lets a URL like myapp://open/project/42 launch or focus your app and jump straight to content.

Custom Protocols

Register a custom URL scheme so the OS knows links of that type belong to your app.

app.setAsDefaultProtocolClient('myapp');

Parsing the Deep Link

Extract the path and parameters from the incoming URL to decide where to navigate.

function parseDeepLink(url) {
  const u = new URL(url);
  return { host: u.host, path: u.pathname };
}
console.log(parseDeepLink('myapp://open/project/42'));

Handling Links on macOS

On macOS, deep links arrive via the open-url event, even while the app is running.

app.on('open-url', (event, url) => {
  event.preventDefault();
  handleLink(url);
});

Handling Links on Windows and Linux

On Windows and Linux the URL comes in as a command-line argument, so inspect process.argv on launch.

function urlFromArgv(argv) {
  return argv.find(a => a.startsWith('myapp://'));
}
console.log(urlFromArgv(['electron', '.', 'myapp://open/5']));

Single Instance Coordination

Use the single instance lock so a second launch forwards its URL to the already-running app instead of starting a new one.

const gotLock = app.requestSingleInstanceLock();
if (!gotLock) app.quit();

second-instance Event

The second-instance event delivers the new command line, where the deep link lives, and lets you focus the main window.

app.on('second-instance', (e, argv) => {
  const url = urlFromArgv(argv);
  if (url) handleLink(url);
});

Cold Start vs Warm Start

Handle both cases: the app launched fresh by the link (cold) and the app already open (warm). Route both to the same handler.

Validating the Link

Never trust a deep link blindly. Validate the path and parameters before acting on them to avoid abuse.

Testing Deep Links

Test by typing the URL into a browser or terminal. During development the scheme must point at your packaged or running app.

Use Cases

Deep links power OAuth callbacks, sharing, and notifications that jump straight to relevant content, tying nicely into the app lifecycle.

Quick Check

Test your deep linking knowledge.

Recap

You learned to register a custom protocol, parse deep links, handle them across platforms, coordinate with the single-instance lock, and validate input, enabling URL-driven app navigation.

Kostenlos starten

Lerne JavaScript mit einem KI-Tutor — kostenlos

Schreibe und führe echten Code in deinem Browser aus, bekomme sofortige Hilfe von einem 24/7 KI-Tutor und setze dein Lernen im Web oder in der App fort.

Kurse
12
Lektionen
47

Häufig gestellte Fragen

Ist die Lektion „Deep Linking und Protokoll-Handler“ kostenlos?

Ja — der vollständige Text von „Deep Linking und Protokoll-Handler“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Electron Desktop App Development-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Electron Desktop App Development-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Deep Linking und Protokoll-Handler“?

Ermöglichen Sie es Nutzern, Ihre Electron-App über benutzerdefinierte URL-Schemata zu starten und zu navigieren – eine wichtige Lifecycle-Integration, die Startup-Ereignisse und Updates ergänzt. Du übst Electron Desktop App Development mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Electron Desktop App Development zu starten?

Keine Vorkenntnisse erforderlich. Electron Desktop App Development auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.

Wie lange dauert die Lektion „Deep Linking und Protokoll-Handler“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Electron Desktop App Development-Lektion Code schreiben und ausführen?

Ja. Jede Electron Desktop App Development-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Ereignisse im App-Lebenszyklus verwalten
  2. Automatische Updates implementieren
  3. Absturzberichte
  4. Deep Linking und Protokoll-Handler
← Zurück zu Electron Desktop App Development