A function that receives a URL string and returns a result indicating how the URL should be handled. Returning
void is treated the same as { systemAction: true }.Returns
AComponent value that is passed to .environment("openURL", ...) to intercept URL requests in the subtree.
Result Types
The callback can return one of theseOpenURLActionResult values:
The URL was handled by your custom logic. No further action is taken.
The URL should be ignored entirely.
Delegate to the platform’s default URL handler.
Open a (possibly rewritten) URL. Set
preferInApp to true to suggest an in-app browser.Usage
Custom scheme handling
Open external URLs in-app
Block certain domains
URL rewriting
Notes
- The action is set via
.environment("openURL", ...)and applies to all child components in the subtree. - Returning
void(no return value) is treated the same as{ systemAction: true }. - The
preferInAppoption is a hint to the platform. Not all platforms support in-app browsers. - The callback is synchronous. Use state updates or actions for async side effects.
- URL validation is your responsibility — the system does not validate URLs before calling your handler.
See Also
- useEnvironment — access environment values including
openURL