# Using Superwall Deep Links

How to use Superwall Deep Links to trigger paywalls or custom in-app behavior.

A Superwall Deep Link is a URL hosted at `https://<subdomain>.superwall.app/app-link/...` that opens your app to trigger a paywall as configured on the Superwall dashboard, or custom in-app behavior via the Superwall delegate.

Prerequisites [#prerequisites]

:::ios
1. Set up [deep link handling](/docs/sdk/quickstart/in-app-paywall-previews)
:::

2. Create a [Web Checkout app](/docs/web-checkout/web-checkout-creating-an-app), even if you do not plan to charge through Web Checkout, this provisions the `*.superwall.app` domain that powers Superwall Deep Links.

Handling incoming links [#handling-incoming-links]

* Always call `handleDeepLink` first. It returns `true` when the SDK recognizes the URL and plans to take over presentation, or `false` when you should continue routing inside your own app.
* When a recognized link arrives before `Superwall.configure(...)` finishes, the SDK caches it and replays it immediately after configuration completes, so it is safe to forward links during cold launch.
* If the return value is `false`, continue with your normal router—those links are not associated with any Superwall experience.

:::ios
```swift
func application(
  _ app: UIApplication,
  open url: URL,
  options: [UIApplication.OpenURLOptionsKey: Any] = [:]
) -> Bool {
  let handled = Superwall.handleDeepLink(url)
  if handled {
    return true
  }

  return routeInternally(url)
}
```
:::

Link formats and campaigns [#link-formats-and-campaigns]

Deep link URLs are hosted at `https://<subdomain>.superwall.app/app-link/...`, you can have anything after the `/app-link/` path, including query parameters. These values will be availble to you in audience filters on the Superwall dashboard, or in the `handleSuperwallDeepLink` delegate method.

:::ios
```swift
final class PaywallDelegate: SuperwallDelegate {
  func handleSuperwallDeepLink(
    _ url: URL,
    pathComponents: [String],
    queryParameters: [String: String]
  ) {
    guard let head = pathComponents.first else { return }

    switch head {
    case "campaign":
      if pathComponents.count > 1 {
        routeToCampaignDetail(id: pathComponents[1])
      }
    default:
      break
    }
  }
}
```
:::

Keep your own routing logic in place for non-Superwall URLs and for any additional behaviors you want to stack on top of Superwall's default presentation flow.

Related deep link guides [#related-deep-link-guides]

:::ios
* [Deep Link Setup](/docs/sdk/quickstart/in-app-paywall-previews) — Configure URL schemes, universal links, and wire `handleDeepLink` into your app so Superwall can respond to incoming links.
* [Handling Deep Links](/docs/sdk/guides/handling-deep-links) — Use `handleDeepLink` with the `deepLink_open` standard placement and dashboard campaign rules to present paywalls from your own deep links, without hardcoding routing logic.
:::