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.
| Method | Returns | Description |
|---|---|---|
init(config) | void | Initializes 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) | () => void | Subscribes 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() | void | Removes all registered listeners. |
getInitialUrl() | string | null | Returns 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 | null | The 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 | null | Returns 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() | DeferredLinkResult | This 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() | void | Removes 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.
useAplikoLink(callback: (url: string | null, data?: UrlSchemeMetaData, meta?: LinkEventMeta) => void): void| Parameter | Type | Description |
|---|---|---|
callback | (url, data, meta) => void | A 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.
| Prop | Type | Description |
|---|---|---|
onLink | (url, data, meta) => void | Optional. Callback for every deep link event. |
children | React.ReactNode | Your 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.
| Export | Description |
|---|---|
AplikoPasteHost | Render 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(). |
AplikoPasteButton | Just 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.
| Method | Returns | Description |
|---|---|---|
AplikoLinkTesting.simulateFreshInstall() | Promise<void> | Makes the next init() behave like the first launch after a fresh install. |
AplikoLinkTesting.setMockDeferredLink(url) | void | Pretends 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.
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
}