Skip to main content

API Reference

Detailed reference for all exported APIs, including the Singleton, Hook, Provider, paste components and testing utilities.

This documentation covers @apliko/react-native-deep-link 0.3.0.

Singleton API: AplikoLink

The core singleton for managing deep links throughout your application. Import it as AplikoLink. Every method except init throws [AplikoLinkManager] Please call init() first if the SDK has not been initialized; getInitialUrlAsync and shouldOfferPaste reject instead of throwing.

MethodReturnsDescription
init(config)voidInitializes the SDK with AplikoLinkManagerConfig (apiKey, debug, enableDeferred, webRuntimeLinks; see Type Definitions). Must be called once, as early as possible, before using any other methods. Throws [AplikoLinkManager] apiKey is required if the key is missing or empty; later calls are ignored until destroy(). Keys are trimmed, and a server key (sv_…) is never sent.
addListener(cb)() => voidSubscribes to deep links. Calls cb(url, data, meta) for every link that arrives while the app is running, in the order the links were opened. The link that launched the app, and a deferred link, are delivered once, to the first listener registered. meta.source is 'initial', 'runtime' or 'deferred'. Returns an unsubscribe function.
removeAllListeners()voidRemoves all registered listeners.
getInitialUrl()string | nullReturns and consumes the link that launched the app (or the deferred link), without data. Returns null if there is no such link, if it was already delivered to a listener or a previous call, or if startup has not finished yet (for example, right after init). Prefer getInitialUrlAsync().
getInitialUrlAsync()Promise<string | null>Like getInitialUrl(), but waits for startup to finish, so calling it right after init is fine. Same once-only rule, shared with listeners (whoever asks first gets it). Never hangs: resolves null when there is no link, after destroy(), or if no launch link arrives in time. Rejects only if init() was never called.
getCurrentLink()CurrentLink | nullThe latest link handed to your listeners, with its Apliko data and source. Never consumed and makes no request, so a screen that mounts later can read it. null before the first link.
getCurrentUrl()string | nullReturns the most recent deep link (or the launch link if no other has arrived) without consuming it.
getDataForUrl(url)Promise<UrlSchemeMetaData>Loads the link's details from Apliko Link. Only Apliko links (on any *.nvgt.link subdomain) are requested, always over HTTPS. It resolves to an empty object if the link data can't be loaded, and for any other URL, for which it sends nothing, so your key is never sent elsewhere. Never rejects.
getDeferredLinkResult()DeferredLinkResultThis launch's deferred-link outcome, always the same shape after init(). url is set only when a deferred link was delivered. See Deferred Deep Linking.
shouldOfferPaste()Promise<boolean>iOS: whether to show your own Paste button UI now (first launch of a fresh install, with a link on the clipboard). false elsewhere.
destroy()voidRemoves all listeners, unsubscribes from platform events and resets the SDK. Mainly for tests and hot reload. init() can be called again right after, even with a different key. A deferred link is never replayed.

Hook API: useAplikoLink

A React hook for handling deep links within functional components. It subscribes on mount and unsubscribes on unmount. It subscribes once for the component's lifetime, so an inline callback is fine: re-renders never re-subscribe, and each link is handled by the callback from the latest render.

typescript
useAplikoLink(callback: (url: string | null, data?: UrlSchemeMetaData, meta?: LinkEventMeta) => void): void
ParameterTypeDescription
callback(url, data, meta) => voidA function that is called every time a new deep link is received. It receives the URL, the link's data and meta.source.

Provider API: AplikoLinkProvider

A React component to wrap your app and handle deep links globally. It renders its children unchanged and does not provide a context. onLink works like the hook's callback: it may be an inline function.

PropTypeDescription
onLink(url, data, meta) => voidOptional. Callback for every deep link event.
childrenReact.ReactNodeYour app's component tree.

Paste components (iOS deferred links)

iOS has no install-referrer API, so deferred links arrive through the system Paste button (iOS 16+, no permission prompt). Enable it with enableDeferred: { ios: true }. All paste UI renders nothing on Android, on web, before iOS 16, when not enabled, and after a link was pasted. Full guide: Deferred Deep Linking.

ExportDescription
AplikoPasteHostRender once near the app root. A floating card or bottom sheet that opens by itself on the first launch of a fresh install when a link is on the clipboard. Props: mode ('auto' default | 'manual'), presentation ('floating' default | 'sheet'), position ('bottom' default | 'top'), title, message, dismissLabel, trigger (label, style, textStyle), containerStyle, titleStyle, messageStyle, dismissStyle, backdropColor (sheet only, 'rgba(0,0,0,0.36)' default), pasteButton, onLink(url), onInvalidContent(), onDismiss().
AplikoPasteButtonJust the system Paste button, for your own screen (for example onboarding). Like the host, it renders only while a deferred link can be offered. Props: displayMode ('iconAndLabel' default | 'iconOnly' | 'labelOnly'), cornerStyle ('capsule' default | 'large' | 'medium' | 'small' | 'fixed'), backgroundColor, foregroundColor, style (height 48 by default), onLink(url), onInvalidContent().
AplikoPaste.show() / .hide()Open or close the host. show() does nothing unless a deferred link can be offered on this launch (iOS 16+, enableDeferred: { ios: true }, first launch of a fresh install, not opened by a link, a link on the clipboard).

Testing utilities: AplikoLinkTesting

Import from @apliko/react-native-deep-link/testing. Development builds only: every method does nothing in release builds.

MethodReturnsDescription
AplikoLinkTesting.simulateFreshInstall()Promise<void>Makes the next init() behave like the first launch after a fresh install.
AplikoLinkTesting.setMockDeferredLink(url)voidPretends url arrived as the deferred link. Call it before init().

Type Definitions

Core TypeScript types used throughout the SDK. url is the link exactly as the device opened it. data contains the link's details from Apliko Link, or an empty object if they could not be loaded.

typescript
export type LinkSource = 'initial' | 'runtime' | 'deferred';

export interface LinkEventMeta {
  source: LinkSource;
}

export type UrlCallback = (
  url: string | null,
  data?: UrlSchemeMetaData,
  meta?: LinkEventMeta
) => void;

export type Unsubscribe = () => void;

export interface CurrentLink {
  url: string;
  data: UrlSchemeMetaData;
  source: LinkSource;
}

export type EnableDeferredConfig =
  | boolean
  | { android?: boolean; ios?: boolean };

export interface AplikoLinkManagerConfig {
  apiKey: string;
  debug?: boolean;
  enableDeferred?: EnableDeferredConfig;           // default { android: true, ios: false }
  webRuntimeLinks?: boolean;                       // default false (web only)
}

export type DeferredLinkSource = 'install_referrer' | 'paste_button';

export interface DeferredLinkResult {
  url: string | null;
  data: UrlSchemeMetaData | null;
  source: DeferredLinkSource | null;
  referrer: string | null;
  isAplikoLink: boolean;
}

export interface UrlSchemeMetaData {
  [x: string]: any;
}

// Paste components (iOS deferred links)
export interface PasteButtonOptions {
  displayMode?: 'iconAndLabel' | 'iconOnly' | 'labelOnly';
  cornerStyle?: 'capsule' | 'large' | 'medium' | 'small' | 'fixed';
  backgroundColor?: string;
  foregroundColor?: string;
  style?: object;
}

export interface AplikoPasteButtonProps extends PasteButtonOptions {
  onLink?: (url: string) => void;
  onInvalidContent?: () => void;
}

export interface AplikoPasteHostProps {
  mode?: 'auto' | 'manual';
  presentation?: 'floating' | 'sheet';
  position?: 'top' | 'bottom';
  trigger?: { label: string; style?: object; textStyle?: object };
  backdropColor?: string;              // sheet only
  pasteButton?: PasteButtonOptions;
  onLink?: (url: string) => void;
  onDismiss?: () => void;
  // also: title, message, dismissLabel, containerStyle, titleStyle,
  // messageStyle, dismissStyle, onInvalidContent
}