wails
wails copied to clipboard
V3 Deep-link (Port of v2 feature)
This is a loose port of the v2 Custom Protocol Association feature initially introduced in #3000
There are some modification to how a user will use the API but the logic of gathering it is fairly similar
A unified Golang API for it is provided to the user regardless of OS as opposed to the v2 solution
app.OnApplicationEvent(events.Common.ApplicationLaunchedWithUrl, func(e *application.ApplicationEvent) {
launchedURL := e.Context().URL() // Retrieve the URL from the event context
log.Printf("Application launched with URL: %s", launchedURL)
})
I have tested on macOS but will need assistance to confirm/troubleshoot other OS, will include my hardware details below
Setting up custom protocol
Configuring the custom protocol is set inside the wails config file
{
"name": "My App",
"description": "An amazing Wails app!",
"info": {
"companyName": "My Company",
"productName": "My Product",
"protocols": [
{
"scheme": "myapp",
"description": "My Application Custom Protocol"
},
{
"scheme": "anotherprotocol",
"description": "Another protocol for specific actions"
}
]
}
}
How it works
The config file will take care of most of the setup for you you will need to run task common:update:build-assets once updating your config file for the changes to take place
In all OS you will need a task package build in order for the custom protocol to work.
MacOS
Values are taken from the config file to populate the correct fields inside the plist
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>My Application Custom Protocol</string> <!-- From Protocol.Description in wails.json -->
<key>CFBundleURLSchemes</key>
<array>
<string>myapp</string> <!-- From Protocol.Scheme in wails.json -->
</array>
</dict>
</array>
Windows
**Requires an NSIS install step and makensis **
Windows will add the URL as an argument to the launch args, wails checks this on start up any launch args match your deep link protocol if so the application event is emitted saving you from having to parse and determine yourself.
Linux
Requires an install step
Linux is setup to configure your deep-link via nfpm and a .desktop file, on install the post-install.sh script will update the device database and MIME types to allow for deep linking.
Linux works similar to windows as it passes the url as an argument to the launch. Wails handles is the same way to populate the application event
Hardware details
Wails (v3.0.0-dev) Wails Doctor
# System
┌──────────────────────────────────────────────────┐
| Name | MacOS |
| Version | 15.4.1 |
| ID | 24E263 |
| Branding | Sequoia |
| Platform | darwin |
| Architecture | arm64 |
| Apple Silicon | true |
| CPU | Apple M4 Pro |
| CPU 1 | Apple M4 Pro |
| CPU 2 | Apple M4 Pro |
| GPU | 16 cores, Metal Support: Metal 3 |
| Memory | 24 GB |
└──────────────────────────────────────────────────┘
# Build Environment
┌─────────────────────────────────────────────────────────┐
| Wails CLI | v3.0.0-dev |
| Go Version | go1.24.1 |
| Revision | 3716acaae4dc0bb6407a7d0a772b32d8509be6d0 |
| Modified | true |
| -buildmode | exe |
| -compiler | gc |
| CGO_CFLAGS | |
| CGO_CPPFLAGS | |
| CGO_CXXFLAGS | |
| CGO_ENABLED | 1 |
| CGO_LDFLAGS | |
| GOARCH | arm64 |
| GOARM64 | v8.0 |
| GOOS | darwin |
| vcs | git |
| vcs.modified | true |
| vcs.revision | 3716acaae4dc0bb6407a7d0a772b32d8509be6d0 |
| vcs.time | 2025-05-14T20:35:41Z |
└─────────────────────────────────────────────────────────┘
Summary by CodeRabbit
-
New Features
- Added comprehensive support for custom protocol schemes (deep linking) across macOS, Windows, and Linux, enabling applications to handle custom URLs.
- Introduced a new example project demonstrating custom protocol handling, including frontend and backend integration.
- Applications now emit events when launched via custom URLs, allowing frontend components to respond accordingly.
-
Documentation
- Added detailed guides and README documentation explaining how to configure and use custom protocol schemes in Wails applications.
-
Chores
- Added configuration files, build scripts, and templates to support packaging, installation, and protocol registration on all major platforms.
Walkthrough
This change introduces comprehensive support for custom protocol schemes (deep linking) in Wails applications across macOS, Windows, and Linux. It includes new documentation, example projects, configuration files, build scripts, and runtime logic. The update adds event types, context handling, and platform-specific implementations to enable applications to register and respond to custom URL schemes, emitting events to the frontend when launched via a registered protocol.
Changes
| Files/Paths | Change Summary |
|---|---|
| docs/src/content/docs/guides/custom-protocol-association.mdx | Added a detailed guide for implementing custom protocol schemes (deep linking) in Wails apps across all major platforms. |
| v3/examples/custom-protocol-example/* (README.md, .gitignore, Taskfile.yml, greetservice.go, main.go, etc.) | Introduced a new example project demonstrating custom protocol usage, including Go backend, frontend assets, build scripts, configuration, and documentation. |
| v3/examples/custom-protocol-example/build/* (darwin, linux, windows, config.yml, etc.) | Added cross-platform build and packaging scripts, configuration files, Info.plist templates, NSIS installer scripts, and Linux packaging support for the example. |
| v3/examples/custom-protocol-example/frontend/* (index.html, src/*, package.json, .gitignore, etc.) | Added frontend implementation for the example, including event handling for URLs, UI, CSS, and generated JS bindings. |
| v3/internal/commands/build-assets.go | Added ProtocolConfig struct and integrated protocol support into build/update config structs and asset update logic. |
| v3/internal/commands/build_assets/linux/nfpm/scripts/postinstall.sh | Replaced empty script with logic to update desktop and MIME databases post-installation, with error handling. |
| v3/internal/commands/updatable_build_assets/darwin/Info.dev.plist.tmpl, Info.plist.tmpl | Updated Info.plist templates to conditionally include custom URL scheme declarations based on provided protocols. |
| v3/internal/commands/updatable_build_assets/linux/desktop.tmpl | Added a Linux desktop entry template supporting protocol MIME type handlers. |
| v3/internal/commands/updatable_build_assets/linux/nfpm/nfpm.yaml.tmpl | Activated postinstall script in nfpm YAML template for Linux packaging. |
| v3/internal/runtime/desktop/@wailsio/runtime/src/event_types.ts | Added new event type constant ApplicationLaunchedWithUrl to the Common event category. |
| v3/pkg/application/application_darwin.go, application_darwin_delegate.h, application_darwin_delegate.m | Added macOS support for handling custom protocol Apple Events, including new handler class, initialization, and event emission. |
| v3/pkg/application/application_linux.go | Extended Linux app to detect and handle custom protocol URLs from command-line arguments, emitting launch events. |
| v3/pkg/application/application_windows.go | Enhanced Windows app to detect and handle custom protocol URLs from command-line arguments, emitting launch events. |
| v3/pkg/application/context_application_event.go | Added/renamed constants and methods to support URL context in application events, including getter/setter for URL. |
| v3/pkg/events/events.txt, events.go | Added new event identifier and struct field for ApplicationLaunchedWithUrl; incremented event IDs accordingly. |
Sequence Diagram(s)
sequenceDiagram
participant OS as Operating System
participant App as Wails Application
participant Backend as Go Backend
participant Frontend as JS Frontend
OS->>App: Launch via custom URL (e.g., myapp://...)
App->>Backend: Emit ApplicationLaunchedWithUrl event with URL context
Backend->>Frontend: Emit frontend event (e.g., "ShowURL") with URL data
Frontend->>Frontend: Display or process received URL
Poem
🐇
A protocol hops through the door,
With URLs it brings to explore.
Mac, Windows, and Linux in sync,
Now apps can respond in a blink!
Events and handlers, all in a row—
Deep linking magic, ready to go.
Let’s celebrate with a joyful wink!
📜 Recent review details
Configuration used: .coderabbit.yaml Review profile: CHILL Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 810dfbb11beff9fc7eee1df33451a3aa78b3e6ed and 101b09676d7eb2cd36fd96ee20ac88574b1e17f1.
📒 Files selected for processing (2)
v3/internal/runtime/desktop/@wailsio/runtime/src/event_types.ts(1 hunks)v3/pkg/events/events.txt(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- v3/pkg/events/events.txt
- v3/internal/runtime/desktop/@wailsio/runtime/src/event_types.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Run Go Tests v3 (ubuntu-latest, 1.24)
- GitHub Check: Run Go Tests v3 (windows-latest, 1.24)
- GitHub Check: Run Go Tests v3 (macos-latest, 1.24)
- GitHub Check: semgrep-cloud-platform/scan
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Explain this complex logic.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai explain this code block.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and explain its main purpose.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
Quality Gate passed
Issues
4 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
Quality Gate passed
Issues
3 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
Thanks @atterpac 🎉