Deep links require a Pro plan subscription or higher.
On Dub, you can create deep links that lets you to redirect users to a specific page within your mobile application.
Deep links on Dub
For example, you’re creating an ad campaign to drive traffic to a specific product page within your mobile app. By following the quickstart guide below, you’ll be able to make sure that all your short links are set up with deep linking functionality. Before you can create deep links, you need to configure your deep link domains in your Dub workspace. This involves adding a custom domain that will be used for your deep links and configuring your deep link configuration files.
1

Add a custom domain

First, you’ll need to add a custom domain to your Dub workspace. Navigate to your workspace domain settings and click Add Domain.You can use a domain you already own, or leverage our free .link domain offer to register a custom domain like yourcompany.link and use it as your deep link domain.
2

Set up your deep link configuration files

Once you’ve set up your custom domain, you’ll need to upload your deep link configuration files to Dub, which we’ll host under the /.well-known/ directory of your domain.To do that, go to your workspace domain settings and click on the edit button for your custom domain:
Deep link configuration files
In the domain modal, click on Show advanced settings, which will open up the Deep Link Configuration settings fields.
Deep link configuration settings
iOS (apple-app-site-association)For iOS apps, upload your Apple App Site Association file to enable iOS deep links:
apple-app-site-association
{
  "applinks": {
    "apps": [],
    "details": [
      {
        "appID": "YOUR_APP_ID",
        "paths": []
      }
    ]
  }
}
Android (assetlinks.json)For Android apps, upload your AssetLinks file to enable Android deep links:
assetlinks.json
[
  {
    "target": {
      "namespace": "android_app",
      "package_name": "YOUR_PACKAGE_NAME",
      "sha256_cert_fingerprints": []
    },
    "relation": ["delegate_permission/common.handle_all_urls"]
  }
]
3

Verify that your configuration files are set up correctly

Once you’ve set up your deep link configuration files, you can go to their respective URLs to verify that they’ve been configured correctly:iOS: yourdomain.link/.well-known/apple-app-site-association (example)Android: yourdomain.link/.well-known/assetlinks.json (example)
4

Whitelist your deep link domain in your app

Last but not least, you’ll need to whitelist your deep link domain in your apps to allow them to redirect straight into a page within your app.For iOS apps, you’ll need to allow websites to link to your apps.For Android apps, you’ll need to verify your Android app links.
Now that you’ve configured your deep link domains, you can create deep links that will redirect users to specific content within your app.
1

Enter your destination URL

Go to your Dub dashboard and click Create Link in the top navigation bar.Enter your destination URL in the “Destination URL” field. You can enter the URL with or without the https:// protocol – behind the scenes, Dub will automatically make sure it’s formatted correctly.This is the URL that opens a specific screen or piece of content within your app. For example https://yourapp.com/product/Apple-MacBook opens the product detail screen for Apple-MacBook.
Deep link builder
2

Set a short link slug

Under the Short Link field, you can either:
  1. Enter your own short link slug
  2. Generate a random short link slug
  3. Generate a short link slug with AI.
For example, you can set a short link slug like apple-macbook to open the product detail screen for Apple-MacBook.
This step is optional. If you don’t enter a short link slug, Dub will generate a random 7-character slug for you.
3

Add device targeting

Device Targeting enables you to redirect users to the App Store or Google Play Store if your app isn’t installed.For example, you can set custom destination URLs for different devices using the link builder — use the iOS Targeting input for iOS devices, and the Android Targeting input for Android devices.
Deep link device targeting configuration
Finally, click Create link to create your deep link. This link will act as a Firebase Dynamic Link replacement.
Dub’s link builder offers many additional features like UTM builder, password protection, expiration dates, geo targeting, and more. Learn more about creating links on Dub to explore all available options.
When a user opens your app from a deep link, you need to handle two main scenarios:

Scenario 1: User has your app installed

When your app is already installed, the deep link will open your app directly. Here’s how to handle it:
1

Detect the deep link

Your app will receive the deep link URL when it opens. The URL will be in the format: https://yourdomain.link/short-link-slug
// App.js
import { useEffect } from "react";
import { Linking } from "react-native";

useEffect(() => {
  const handleDeepLink = (url) => {
    try {
      // Call the tracking endpoint with the full deep link URL
      trackDeepLinkClick(url);
    } catch (error) {
      console.error("Error handling deep link URL:", error);
    }
  };

  // Handle deep link when app is already running
  const subscription = Linking.addEventListener("url", (event) => {
    handleDeepLink(event.url);
  });

  // Handle deep link when app is opened from a deep link
  Linking.getInitialURL().then((url) => {
    if (url) {
      handleDeepLink(url);
    }
  });

  return () => {
    subscription?.remove();
  };
}, []);
2

Track the deep link open

Once you’ve detected and parsed the deep link, you should track the open event using Dub’s API, which will return the final destination URL in the API response.To do this, make a POST request to the endpoint https://api.dub.co/track/open with the following body:
{
  "deepLink": "https://yourdomain.link/short-link-slug"
}
The response will be a JSON object with the following structure if the request is successful:
{
  "clickId": "ASltDhoxBiBqKH00",
  "link": {
    "id": "link_1K9XQTLF7OSH3Z48DKQ5WSRVY",
    "domain": "yourdomain.link",
    "key": "short-link-slug",
    "url": "https://yourapp.com/product/Apple-MacBook"
  }
}
Now you’ve got the destination URL (via link.url), you can navigate the user to the correct screen in your app.Here’s the full example code for React Native, iOS, and Android.
// DeepLinkTracker.js
async function trackDeepLinkClick(deepLink) {
  try {
    const response = await fetch(`https://api.dub.co/track/open`, {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        deepLink,
      }),
    });

    if (response.ok) {
      const data = await response.json();
      const destinationUrl = data.link.url;

      // Navigate to the destination URL in your app
      navigateToDestination(destinationUrl);
    }
  } catch (error) {
    console.error("Error tracking deep link:", error);
  }
}

Scenario 2: User doesn’t have your app installed

When your app isn’t installed, the user will be redirected to the App Store or Google Play Store since you’ve enabled device targeting in Step 2 above. After they install and open your app, you’ll need to use deferred deep linking to:
  1. Retrieve the short link that brought the user to the app store
  2. Track the open event via /track/open
  3. Redirect the user to the final destination URL
For detailed implementation of deferred deep linking, including how to use the Google Play Store Install Referrer API and other services, see our Deferred Deep Linking guide.
Before deploying your deep links to production, test them thoroughly using emulators to ensure they work correctly.
1

Test on Android emulator

Use the Android Debug Bridge (adb) to test your deep links on an Android emulator:
adb shell am start -W -a android.intent.action.VIEW -d "https://yourdomain.link/your-short-link" com.yourpackage.name
2

Test on iOS simulator

Use the xcrun command to test your deep links on an iOS simulator:
xcrun simctl openurl booted "https://yourdomain.link/your-short-link"
3

Test on your device

You can also test your deep links by opening them from a messaging app on your device:
  1. Open a messaging app (like Messages, WhatsApp, or Telegram) on your device
  2. Send yourself a message containing your deep link URL
  3. Tap on the link in the message
  4. The link should either open your app directly or redirect to the appropriate app store