React Native SDK reference

Everything in @straitlink/react-native 0.11.6, in one place.

On this page 7
  1. createStrait(config)
  2. Methods
  3. The link event
  4. Deferred match only
  5. User consent (opt-out)
  6. How installs are matched
  7. iPhone clipboard boost (optional)

createStrait(config)

Option Type Notes
publishableKey string Required. st_pub_live_…, from Dashboard → Setup → Your keys
endpoint string Required. Your link domain, https://<handle>.strait.link
storage { getItem, setItem } Pass AsyncStorage. Keeps the once-per-install flag and unsent open reports
installReferrer () => Promise<string | null> fromPlayInstallReferrer(PlayInstallReferrer) for exact Android installs
installTime () => Promise<number | null> The app's install time, epoch ms: Expo async () => (await Application.getInstallationTimeAsync()).getTime() (expo-application), bare React Native getFirstInstallTime() from react-native-device-info. A reinstall from a link runs the deferred check again, even after a backup restores the app's storage. An app update doesn't
appVersion string Your app's version, sent with each open and install report (with the SDK's own version) so support can see which build opened a link. Expo: Application.nativeApplicationVersion ?? undefined
linkHosts string[] Extra hosts that serve your links. With one link domain you don't need it
clipboardBoost boolean Deprecated, ignored. Paste handoff is switched on in the dashboard. See the clipboard boost
clipboard { hasProbableWebUrl, readText } Clipboard access for paste handoff: fromExpoClipboard(Clipboard). Used only when your workspace has paste handoff on

Methods

Method What it does
start() Reads the launch link, listens for new ones and runs the deferred check once per install. Call once
onLink(cb) Every link event, including ones before you subscribed. Returns an unsubscribe function
onLinkStart(cb) A link just arrived and is being resolved (for a loading state). Returns an unsubscribe function
trackEvent(name, { value?, currency?, linkId?, clickId?, eventId? }) Records an event. Resolves true when accepted. eventId is your order id, counted once; left out, the SDK makes one. An event it can't send (offline, server busy) is kept and sent later. See Events & revenue
checkDeferred() Re-runs the deferred check (debugging). Never records an install
claimHandoff(text) Claims a clipboard-boost link your app got itself, for example from Apple's Paste button
pendingOpenReports() How many open reports are waiting to be sent
flushOpenReports() Sends them now (also happens on start and on resume)
setEnabled(enabled) / isEnabled() Opt-out switch for consent flows (see below). Kept across launches; default on
setUserId(id) Your own user id for later events' app.event webhooks (userId); null on sign-out. Memory only; emails and phone numbers are hashed on the device (how)
stop() Stops listening for links and app-state changes
Field Meaning
kind direct (a link opened the app) or deferred (tapped before install)
route app_link (verified link), custom_scheme (browser hand-off), install_referrer (Google Play), fingerprint (iPhone install match) or clipboard (iPhone clipboard boost)
appState closed (the link launched the app), background or foreground
matched true when the link resolved to a destination
reason Why matched is false: not_found, expired, password_protected, no_match, network or invalid_url
url, path, params The destination: full URL, its path (/product/42) and its query parameters
rawUrl The URL the phone handed the app
linkId The id of the Strait link
id This open's id (not the link's). The same id is on the matching onLinkStart signal
ms How long resolving took, in milliseconds
at When the link arrived (epoch milliseconds)

Deferred match only

If you only want the first-open-after-install destination, there's a one-call API. It never throws; on any error it returns { matched: false, matchMethod: 'none' }.

TypeScript
import { resolveDeferredLink, splitUrl } from '@straitlink/react-native';
import { navigationRef, openPath } from './navigation';

const result = await resolveDeferredLink({
  publishableKey: 'st_pub_live_…',
  endpoint: 'https://hilltop.strait.link',
});
const dest = result.matched && result.longUrl ? splitUrl(result.longUrl) : null;
if (dest && navigationRef.isReady()) openPath(dest.path, dest.params);

If your app asks for consent first (for example under India's DPDP Act or a GDPR consent flow in the EU), call await links.setEnabled(false) until the person agrees: Strait then sends no open reports or events, does no install matching, and deletes reports waiting on the device. The choice is kept across launches; setEnabled(true) turns it back on and isEnabled() reads it. A Strait short link still opens the right screen: it is looked up without recording a tap, an open or a tap id. The legacy resolveDeferredLink honours the same switch when you pass it the same storage. Whether you need consent, and for what, is a question for your own legal advice.

How installs are matched

Platform Method Precision
Android Play Install Referrer Exact
iPhone, device matching on (opt-in) Short-lived device match Probabilistic
iPhone, paste handoff on (opt-in) One-time link from the tap page Exact

See Deferred deep linking and How iPhone install matching works for exactly what's collected and how long it's kept.

iPhone clipboard boost (optional)

Also called paste handoff. You switch it on or off in Dashboard → Settings → iPhone installs → Paste handoff, with no app release: the SDK reads the setting from /v1/match on the first launch and never keeps it. Pass a clipboard adapter once so the SDK can read the clipboard when your workspace asks for it. Without an adapter, or with paste handoff off, the SDK never touches the clipboard. The old clipboardBoost: true option is deprecated and ignored.

TypeScript
import * as Clipboard from 'expo-clipboard';
import { createStrait, fromExpoClipboard } from '@straitlink/react-native';

export const links = createStrait({
  publishableKey: 'st_pub_live_…',
  endpoint: 'https://hilltop.strait.link',
  clipboard: fromExpoClipboard(Clipboard), // used only when paste handoff is on
});

On the first launch only, and only when device matching found nothing and paste handoff is on, the SDK asks whether the clipboard probably holds a web link (iOS answers without a prompt). Only if it does, it reads the text, and iOS shows its Allow Paste prompt. Anything that isn't a Strait handoff link never leaves the phone.