Expand description
Standalone “open URL” hook: usable without the full Shell plugin.
One process-wide hub receives every URL the OS hands the app and fans it out to handlers:
- macOS / iOS: Apple Event URLs (
tauri::RunEvent::Opened { urls }) throughhandle_run_event. - Windows / Linux: URLs on the command line at cold start (
capture_launch_args) and URLs on the argv of a second launch, forwarded bycrate::instance(deliver_second_instance, orinit_single_instancewhich wires both).
URLs that arrive before any handler is registered (cold start) are buffered and readable with
current_urls; on_open_url handlers receive URLs that arrive after registration. The
same URL delivered twice within DEDUP_WINDOW (for example argv and an Apple Event for one
click) reaches handlers once.
Scheme registration (mailto:, custom schemes) stays with the app’s installer or bundle
(CFBundleURLTypes, NSIS/MSI protocol entries, .desktop MIME types). This module only
delivers what the OS already routed to the process. The full Shell plugin feeds the same hub,
so handlers registered here also see its deliveries.
Structs§
Constants§
- DEDUP_
WINDOW - The same URL seen again inside this window is a duplicate delivery.
Functions§
- capture_
launch_ args - Deliver the URLs on this process’s command line (Windows/Linux cold start). Call once, early.
- current_
urls - URLs that arrived before the first
on_open_urlhandler was registered (cold start). - deliver
- Deliver URLs from any source the app owns (for example a custom IPC). Returns how many were new.
- deliver_
second_ instance - Deliver the URLs on a second launch’s argv (
argv[0]is the executable and is skipped). - handle_
run_ event - Feed Apple Event URLs from the Tauri run loop: call it for every event in
app.run(|_, event| rightkit_tauri_shell::open_url::handle_run_event(&event)). A no-op elsewhere. - hub
- The process-wide hub.
- init_
single_ instance - Single-instance arbitration wired to this hub, with no Shell plugin. The primary process
captures its own launch URLs; a second launch forwards its argv to the primary and the caller
must exit on
Arbitration::Secondary. Keep thePrimaryguard alive for the process lifetime. - is_url
- True for
scheme:restwhere the scheme is at least two characters, so Windows drive paths such asC:\mailare not URLs. Control characters and over-long input are rejected. - on_
open_ url - Register a handler for URLs the OS opens in this app from now on.
- urls_
from_ args - The URL-shaped entries of a command line (flags, paths and drive letters are skipped).
Type Aliases§
- UrlHandler
- Receives a batch of URLs that arrived together.