Skip to main content
(url: string) => OpenURLActionResult | void
required
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

A Component value that is passed to .environment("openURL", ...) to intercept URL requests in the subtree.

Result Types

The callback can return one of these OpenURLActionResult values:
object
The URL was handled by your custom logic. No further action is taken.
object
The URL should be ignored entirely.
object
Delegate to the platform’s default URL handler.
object
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 preferInApp option 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