Skip to main content

Installation

npm install despia-native
import despia from 'despia-native';
Deep linking routes users to the correct page inside your app from an ad, campaign link, or creator affiliate link. Despia handles both cases: users who already have the app installed and users who install after clicking a link (deferred deep linking). Your web layer only needs to read the values and render the correct page.
Deferred deep linking works even if the user installed the app days after clicking the link. AppsFlyer stores the click data and delivers it on first launch.

How it works

Despia handles navigation automatically. When a deep link is resolved, the native layer navigates the WebView to the correct path directly. Your web app just renders whatever page it lands on, the same way it handles any other URL.
1

Create a OneLink URL

In your AppsFlyer dashboard, go to Engage > OneLink Management and create a campaign link with deep_link_value and any custom params like page_id or creator_code.
2

Use the link in your ads or share with creators

Paste the generated OneLink URL into your TikTok or Meta ad creative, or give it to a content creator as their affiliate link.
3

Your web app renders the page

Despia navigates the WebView automatically. Your web router handles the path like any normal page load.

This is the most important setup step. deep_link_value is not magic. It is a plain string that Despia appends to your app’s base URL to build a path. If that path does not exist as a real route in your web app, the user will land on a blank page or 404. How the mapping works:
deep_link_value = "product"
page_id         = "sneaker_42"
creator_code    = "alex123"

Despia navigates WebView to:
https://yourapp.com/product?page_id=sneaker_42&creator_code=alex123
Your web app must have a route at /product that reads page_id and creator_code from the query string and loads the correct content. Step 1: Decide your deep link routes Before creating any OneLink URLs, decide which pages you want to support as deep link destinations. Keep values short and URL-safe.
deep_link_valueRoute in your appUse case
product/productLand on a specific product page
collection/collectionLand on a curated collection
profile/profileLand on a creator or user profile
offer/offerLand on a special offer or promo page
onboarding/onboardingStart a custom onboarding flow
home/Default home screen
Step 2: Add the routes to your web app Each deep_link_value must have a corresponding route in your client-side router. Here is how to handle the query params:
// App.jsx
import { Routes, Route, useSearchParams } from 'react-router-dom'

function ProductPage() {
    const [params] = useSearchParams()
    const pageId      = params.get('page_id')
    const creatorCode = params.get('creator_code')

    // load the product and apply any creator discount/tracking
    useEffect(() => {
        loadProduct(pageId)
        if (creatorCode) trackCreatorReferral(creatorCode)
    }, [pageId, creatorCode])

    return <div>...</div>
}

export default function App() {
    return (
        <Routes>
            <Route path="/"            element={<Home />} />
            <Route path="/product"     element={<ProductPage />} />
            <Route path="/collection"  element={<CollectionPage />} />
            <Route path="/profile"     element={<ProfilePage />} />
            <Route path="/offer"       element={<OfferPage />} />
            <Route path="/onboarding"  element={<OnboardingPage />} />
        </Routes>
    )
}
Step 3: Use the exact same value in your OneLink URL Whatever route path you set up in your web app, use the same string (without the leading slash) as deep_link_value in your OneLink campaign URL.
deep_link_value=product     ✓  matches route /product
deep_link_value=Product     ✗  wrong case, route won't match
deep_link_value=product-page ✗  wrong slug, route won't match
deep_link_value is case-sensitive and must exactly match your route path without the leading slash. If the route does not exist in your web app, the user will land on your app’s 404 or fallback page.

Even though Despia navigates automatically, the full deep link data is also available in despia.appsFlyerAttribution on every page load. Use this to personalize content based on the campaign or creator params.
import despia from 'despia-native';

const attr = despia.appsFlyerAttribution

const deepLinkValue = attr.deep_link_value  // e.g. "product"
const pageId        = attr.page_id          // e.g. "sneaker_42"
const creatorCode   = attr.deep_link_sub1   // e.g. "alex123"
const sub2          = attr.deep_link_sub2   // additional routing param
The main routing value. Despia navigates the WebView to this path automatically, e.g. "product", "collection", "offer"
page_id
string
A specific content ID to load on the destination page, e.g. a product ID, collection ID, or profile ID
General-purpose sub-parameter. Commonly used for creator or affiliate codes.
General-purpose sub-parameter for additional routing context

Personalize the Page on Load

import despia from 'despia-native';

const attr = despia.appsFlyerAttribution

if (attr.page_id) {
    loadProduct(attr.page_id)
}

if (attr.deep_link_sub1) {
    // show creator welcome message or apply their promo
    showCreatorWelcome(attr.deep_link_sub1)
}

Deep linking works great for content creator and influencer affiliate campaigns. Each creator gets their own OneLink URL with their unique code. When a user installs via a creator link, you know exactly which creator drove the install and can attribute credit, apply discounts, or personalize the welcome experience. Example creator link:
https://yourapp.onelink.me/xxxx?pid=influencer_int&c=summer_campaign&deep_link_value=product&page_id=sneaker_42&deep_link_sub1=alex123
When the user opens the app:
import despia from 'despia-native';

const attr = despia.appsFlyerAttribution

// deep_link_sub1 carries the creator's affiliate code
const creatorCode = attr.deep_link_sub1  // "alex123"
const productId   = attr.page_id         // "sneaker_42"

if (creatorCode) {
    // show "You were referred by Alex" welcome screen
    showCreatorWelcomeScreen(creatorCode)

    // apply creator's discount or track commission
    applyCreatorDiscount(creatorCode)

    // log the referral event back to AppsFlyer
    const referral = {
        "af_sub1": creatorCode,
        "af_content_id": productId
    }
    despia("appsflyer://log_event?event_name=creator_referral&event_values=" + encodeURIComponent(JSON.stringify(referral)))
}
Use deep_link_sub1 through deep_link_sub5 for creator and affiliate parameters. These map cleanly to AppsFlyer’s af_sub1 through af_sub5 fields which are available in raw data exports and the AppsFlyer dashboard for commission reporting.

For re-engagements, when a user who already has the app installed taps a campaign or creator link while the app is open, Despia calls window.onAppsFlyerDeepLink with the full click event data. Define this function to handle routing when the app is already running.
window.onAppsFlyerDeepLink = (data) => {
    const deepLinkValue = data.deep_link_value
    const pageId        = data.page_id
    const creatorCode   = data.deep_link_sub1

    if (deepLinkValue === "product") {
        window.location.href = `/product?page_id=${pageId}&creator_code=${creatorCode}`

    } else if (deepLinkValue === "offer") {
        window.location.href = `/offer?id=${pageId}`

    } else if (deepLinkValue === "profile") {
        window.location.href = `/profile?id=${pageId}`
    }
}
Define window.onAppsFlyerDeepLink as early as possible in your app, ideally at the top level of your entry file, so it is always available when Despia calls it.

https://yourapp.onelink.me/xxxx?pid=tiktokads_int&c=summer_2025&deep_link_value=product&page_id=sneaker_42&deep_link_sub1=alex123
The main routing destination. Despia uses this to navigate the WebView to the correct path automatically.
page_id
string
A specific content ID to load on the destination page
General-purpose sub-parameter. Commonly used for creator codes, affiliate IDs, or promo codes.
General-purpose sub-parameter for additional context
pid
string
Media source identifier, e.g. "tiktokads_int", "facebook", "influencer_int". Set in the AppsFlyer dashboard.
c
string
Campaign name for attribution and reporting

Despia Dashboard Setup

All deep linking configuration is handled directly in the Despia dashboard. No code changes, no native setup required.
1

Open AppsFlyer Integration

Go to Despia > App > Settings > Integrations > AppsFlyer
2

Add your OneLink URLs

Enter your OneLink subdomain and any OneLink URLs you want the app to handle as deep links
3

Add your ad platform IDs

Enter your Facebook App ID, TikTok App ID, AdMob App ID, and any other ad platform credentials in the same screen
4

Save and rebuild

Save the configuration and rebuild your app. Despia handles all the native plumbing automatically.
Despia configures Universal Links automatically based on the OneLink URLs you enter in the dashboard. No entitlements files, no native developer involvement required.
Despia also registers the appsflyer:// URI scheme automatically. This is an AppsFlyer SDK requirement for URI scheme deep linking fallback — it allows deep links to open the app when Universal Links are unavailable, for example in some in-app browsers or older iOS versions. This is separate from Despia’s internal web bridge commands and requires no configuration on your part.

Frequently Asked Questions

Yes. When a deep link is resolved natively, Despia builds the full URL from deep_link_value and any custom params, then navigates the WebView to that path directly. Your web app handles it like any normal page load. You do not need to implement any navigation logic for this case.
Yes. AppsFlyer stores the click data server-side with a configurable lookback window (default 7 days). When the user installs and opens the app within that window, the deep link parameters are delivered on first launch and Despia navigates automatically.
Give each creator a unique OneLink URL with their code in deep_link_sub1. In your AppsFlyer dashboard, filter raw data by af_sub1 to see installs, events, and revenue per creator. You can also fire a custom creator_referral event on first launch to track conversions per creator in your own backend.

Resources

NPM Package

Install the Despia SDK

AppsFlyer OneLink Docs

Create and manage OneLink campaign URLs

Support

Contact our support team