Current SDK release: 0.2.15 (September 2026).
Use the browser SDK for link resolution and attribution in a SPA or client-rendered component. For SSR, initialize it only in the browser.
Install
npm install @li-nk.me/web-sdk@^0.2.15
Expose only an app ID and optional read-only app key through your framework's public environment variables. Keep server write keys on the backend.
Next.js App Router example
Mount this provider once inside the app layout. Use a client instance per provider so teardown cannot dispose another provider's SDK instance.
'use client';
import { type ReactNode, useEffect } from 'react';
import { useRouter } from 'next/navigation';
import { LinkMeWebClient, type LinkMePayload } from '@li-nk.me/web-sdk';
export function LinkMeProvider({ children }: { children: ReactNode }) {
const router = useRouter();
useEffect(() => {
const client = new LinkMeWebClient();
let active = true;
let subscription: { remove: () => void } | undefined;
const route = (payload: LinkMePayload | null) => {
const path = payload?.path;
// Only route known internal destinations; extend this allowlist for your app.
if (active && path && /^\/products\/[a-zA-Z0-9_-]+$/.test(path)) {
router.replace(path);
}
};
void (async () => {
await client.configure({
baseUrl: 'https://links.yourco.com',
appId: process.env.NEXT_PUBLIC_LINKME_APP_ID!,
appKey: process.env.NEXT_PUBLIC_LINKME_APP_READ_KEY,
autoResolve: false,
});
if (!active) return;
const initial = await client.resolveFromUrl();
if (!active) return;
if (initial) route(initial);
else route(await client.claimDeferredIfAvailable());
if (!active) return;
subscription = client.onLink(route);
})().catch((error) => {
if (active) console.error('LinkMe initialization failed', error);
});
return () => {
active = false;
subscription?.remove();
client.dispose();
};
}, [router]);
return <>{children}</>;
}
For React, Vue, Svelte, or Angular, use the same sequence in the framework's mount/init lifecycle and remove subscriptions and dispose the client during teardown. Call setUserId(null) on the same client on logout.
Verify the integration
- Test a URL containing a fresh
cid, a direct URL, and a URL without a matching payload. - Test navigation, unmount/remount, and logout while requests are pending.
- Check network responses and confirm the destination is an allowed internal route.
- Fingerprint attribution is probabilistic; an incognito session alone does not prove first-install attribution.
See the Web SDK reference for configuration, payload fields, and analytics APIs.