<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/onOpenURL(perform:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE9onOpenURL7performQry10Foundation0F0Vc_tF"
  },
  "title" : "onOpenURL(perform:)"
}
-->

# onOpenURL(perform:)

Registers a handler to invoke in response to a URL that your app
receives.

```
nonisolated func onOpenURL(perform action: @escaping (URL) -> ()) -> some View
```

## Parameters

`action`

A closure that SwiftUI calls when your app receives
a Universal Link or a custom
<doc://com.apple.documentation/documentation/Foundation/URL>.
The closure takes the URL as an input parameter.

## Return Value

A view that handles incoming URLs.

## Discussion

Use this view modifier to receive URLs in a particular scene within your
app. The scene that SwiftUI routes the incoming URL to depends on the
structure of your app, what scenes are active, and other configuration.
For more information, see [`handlesExternalEvents(matching:)`](/documentation/SwiftUI/Scene/handlesExternalEvents(matching:)).

UI frameworks traditionally pass Universal Links to your app using an
<doc://com.apple.documentation/documentation/Foundation/NSUserActivity>.
However, SwiftUI passes a Universal Link to your app directly as a URL,
which you receive using this modifier. To receive other user activities,
like when your app participates in Handoff, use the
[`onContinueUserActivity(_:perform:)`](/documentation/SwiftUI/View/onContinueUserActivity(_:perform:)) modifier instead.

For more information about linking into your app, see
<doc://com.apple.documentation/documentation/Xcode/allowing-apps-and-websites-to-link-to-your-content>.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)