Skip to main content
Version: 2.0.0

API Reference

DetourProvider

Top-level React component that initializes link handling and analytics event transport.

Signature

function DetourProvider(props: {
config: Config;
children: React.ReactNode;
}): JSX.Element;

Web behavior

On Platform.OS === 'web', provider initialization is skipped. DetourProvider returns a no-op context value:

  • isLinkProcessed: true
  • link: null
  • clearLink: () => {}

In development builds, the SDK logs a single warning: [Detour:WEB_UNSUPPORTED].

Config fields

FieldTypeRequiredDefaultDescription
appIDstringYes-App identifier from Detour dashboard
apiKeystringYes-Publishable API key from Detour dashboard
shouldUseClipboardbooleanNotrueiOS-only clipboard read for probabilistic matching
linkProcessingModeLinkProcessingModeNo'all'Controls which link sources are handled
storageDetourStorageNoAsyncStorageCustom storage adapter for SDK persistence keys

useDetourContext

Hook that returns link-processing state and the resolved link payload.

Signature

function useDetourContext(): DetourContextType;

Returned object

PropertyTypeDescription
isLinkProcessedbooleantrue when initial processing (or fallback) finished
linkDetourLinkResolved link object or null
clearLink() => voidClears current link state

DetourAnalytics

Analytics helper exported from the package root.

Methods

DetourAnalytics.logEvent(
eventName: DetourEventNames | `${DetourEventNames}`,
data?: any,
): void;

DetourAnalytics.logRetention(retentionEventName: string): void;

Expo Router helper

Available under subpath import:

import { createDetourNativeIntentHandler } from '@swmansion/react-native-detour/expo-router';

Signature

function createDetourNativeIntentHandler(
options?: DetourNativeIntentOptions,
): DetourNativeIntentHandler;

Key options

OptionTypeDescription
fallbackPathstringReturned when Detour host matches and resolve mode is disabled/fails
hostsArray<string | RegExp>Host match patterns (default: *.godetour.link)
config{ apiKey; appID; timeoutMs?; onResolveError? }Enables short-link resolve mode
mapToRoute(value) => stringCustom route mapping after resolution

Types

LinkProcessingMode

type LinkProcessingMode = 'all' | 'web-only' | 'deferred-only';

LinkType

type LinkType = 'deferred' | 'verified' | 'scheme';
type DetourLink = {
url: string | URL;
route: string;
pathname: string;
params: Record<string, string>;
type: LinkType;
} | null;

DetourContextType

type DetourContextType = {
isLinkProcessed: boolean;
link: DetourLink;
clearLink: () => void;
};

DetourStorage

interface DetourStorage {
getItem(key: string): Promise<string | null> | string | null;
setItem(key: string, value: string): Promise<void> | void;
removeItem?(key: string): Promise<void> | void;
}

DetourEventNames

CategoryEvent NameString Value
GeneralLoginlogin
Searchsearch
Shareshare
SignUpsign_up
TutorialBegintutorial_begin
TutorialCompletetutorial_complete
ReEngagere_engage
Inviteinvite
OpenedFromPushNotificationopened_from_push_notification
SalesAddPaymentInfoadd_payment_info
AddShippingInfoadd_shipping_info
AddToCartadd_to_cart
RemoveFromCartremove_from_cart
Refundrefund
ViewItemview_item
BeginCheckoutbegin_checkout
Purchasepurchase
AdImpressionad_impression