{"_id":"@ashishsoni1234/react-native-smartlink","name":"@ashishsoni1234/react-native-smartlink","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@ashishsoni1234/react-native-smartlink","version":"0.1.0","description":"React Native SDK for Deeplink deep linking and deferred attribution","license":"MIT","publishConfig":{"access":"public"},"main":"./dist/index.js","types":"./dist/index.d.ts","react-native":"./dist/index.js","exports":{".":{"react-native":"./dist/index.js","types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js","default":"./dist/index.js"}},"scripts":{"build":"tsup src/index.ts --format cjs,esm --dts --external react --external react-native","dev":"tsup src/index.ts --format cjs,esm --dts --watch --external react --external react-native","typecheck":"tsc --noEmit","lint":"eslint src/","clean":"rm -rf dist","prepublishOnly":"pnpm run build"},"peerDependencies":{"react":"*","react-native":"*"},"devDependencies":{"@deeplink/eslint-config":"workspace:*","@deeplink/tsconfig":"workspace:*","@types/react":"^19.1.6","eslint":"^9.28.0","react":"^19.1.0","react-native":"^0.79.2","tsup":"^8.5.0","typescript":"^5.8.3"},"_id":"@ashishsoni1234/react-native-smartlink@0.1.0","gitHead":"3292974ad1d25653d9f8c7c6183d34f03cd80bd0","_nodeVersion":"22.23.1","_npmVersion":"10.9.8","dist":{"integrity":"sha512-R/uFXjRdgSu1M9vQ9ICw1x7TmKWFjOXAhlhKs/TL8OoPTMnv3l7ahh1pA1UwXRaFetT28n1oi9FkBuRgkW0sng==","shasum":"1b0a2ecc9a43c32c3b3cafffc34c806626791f0d","tarball":"https://registry.npmjs.org/@ashishsoni1234/react-native-smartlink/-/react-native-smartlink-0.1.0.tgz","fileCount":6,"unpackedSize":34314,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIH8TTFWnm4+VdbhykL44XHmkhN6+4j0GPhPDykL79jfyAiAQL8iWOv+mPGz7x0rGBc4gXJGStBn0VoJtz4Dg5olfYw=="}]},"_npmUser":{"name":"ashishsoni1234","email":"soni.ashish@dotsquares.com"},"directories":{},"maintainers":[{"name":"ashishsoni1234","email":"soni.ashish@dotsquares.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/react-native-smartlink_0.1.0_1784010519490_0.8443515946745286"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-14T06:28:39.355Z","0.1.0":"2026-07-14T06:28:39.643Z","modified":"2026-07-14T06:28:39.826Z"},"maintainers":[{"name":"ashishsoni1234","email":"soni.ashish@dotsquares.com"}],"description":"React Native SDK for Deeplink deep linking and deferred attribution","license":"MIT","readme":"# react-native-smartlink\n\nReact Native / Expo SDK for **SmartLink** — deep links, deferred deep linking, and typed API helpers.\n\n## Requirements\n\n- React Native `0.73+` (or Expo SDK that ships a compatible RN)\n- `react` and `react-native` as peer dependencies\n- A running SmartLink **backend API** and **redirect server** (staging or self-hosted)\n\n## Install\n\n```bash\nnpm install react-native-smartlink\n# or\nyarn add react-native-smartlink\n# or\npnpm add react-native-smartlink\n```\n\nPeers (usually already present in an RN/Expo app):\n\n```bash\nnpm install react react-native\n```\n\n## Quick start\n\n```tsx\nimport { useEffect } from 'react';\nimport { createDeeplinkSDK } from 'react-native-smartlink';\n\nconst sdk = createDeeplinkSDK({\n  apiKey: 'your-api-key',\n  apiUrl: 'https://api-smartlink.example.com',\n  redirectUrl: 'https://go-smartlink.example.com',\n});\n\nexport function DeepLinkBootstrap() {\n  useEffect(() => {\n    const unsubscribe = sdk.onDeepLink((params) => {\n      // Cold start + runtime links\n      // params.shortCode, params.query, params.customParams, ...\n      console.log('Deep link:', params);\n    });\n\n    return () => {\n      unsubscribe();\n      sdk.stop();\n    };\n  }, []);\n\n  return null;\n}\n```\n\n`onDeepLink` starts Linking listeners automatically. You can also call `sdk.start()` / `sdk.stop()` yourself.\n\n## Configuration\n\n| Option | Required | Description |\n|--------|----------|-------------|\n| `apiKey` | Yes | API key sent as `X-API-Key` on deferred match |\n| `apiUrl` | No | Backend base URL (default `http://localhost:5000`) |\n| `redirectUrl` | No | Redirect / link domain base URL (default `http://localhost:4000`) |\n\n### Environment variables (recommended)\n\n```bash\nEXPO_PUBLIC_API_URL=https://api-smartlink.example.com\nEXPO_PUBLIC_REDIRECT_URL=https://go-smartlink.example.com\nEXPO_PUBLIC_APP_SCHEME=myscheme\n```\n\n```ts\nconst sdk = createDeeplinkSDK({\n  apiKey: process.env.EXPO_PUBLIC_API_KEY ?? 'your-api-key',\n  apiUrl: process.env.EXPO_PUBLIC_API_URL,\n  redirectUrl: process.env.EXPO_PUBLIC_REDIRECT_URL,\n});\n```\n\n## Deep link listener\n\n```ts\nconst unsubscribe = sdk.onDeepLink((params) => {\n  // params.url\n  // params.path\n  // params.shortCode\n  // params.query          // all query string key/values\n  // params.customParams\n  // params.deferred       // true when from deferred match\n});\n```\n\nUses React Native `Linking`:\n\n- Cold start: `Linking.getInitialURL()`\n- Runtime: `Linking.addEventListener('url', ...)`\n\n## Parse a URL manually\n\n```ts\nimport { parseDeepLinkParams } from 'react-native-smartlink';\n\nconst params = parseDeepLinkParams('myscheme://product/123?campaign=spring');\n// params.shortCode, params.query, ...\n```\n\nAlso works with https Universal / App Links:\n\n```ts\nparseDeepLinkParams('https://go-smartlink.example.com/abc123?utm_source=email');\n```\n\n## Deferred deep linking\n\nAfter install (user opened a SmartLink before the app was installed):\n\n```ts\nconst result = await sdk.getDeferredDeepLink();\n\nif (result.matched && result.params) {\n  // Navigate using result.params\n}\n\n// Full server payload:\nresult.raw; // DeferredMatchResponse\n```\n\nCalls `POST {redirectUrl}/v1/deferred/match`. If you omit a fingerprint, the server can derive one from IP + User-Agent.\n\nOptional fingerprint:\n\n```ts\nawait sdk.getDeferredDeepLink('optional-client-fingerprint');\n```\n\n## Navigation helpers\n\nWire the SDK to React Navigation / Expo Router:\n\n```ts\nsdk.setNavigator((screen, params) => {\n  // navigation.navigate(screen, params)\n});\n\nsdk.navigateToScreen('ProductDetail', { productId: '123' });\n```\n\n## Custom events (in-memory queue)\n\n```ts\nsdk.trackEvent('purchase', { amount: 99.99 });\nsdk.getQueuedEvents(); // until server ingestion is enabled\n```\n\n## Typed API client\n\n```ts\nconst client = sdk.getApiClient();\n\nawait client.getBackendHealth();\nawait client.getRedirectHealth();\nawait client.matchDeferred({ fingerprint: 'optional' });\n```\n\n## Native setup (scheme + Universal / App Links)\n\nThe SDK listens to URLs the OS delivers. You still must register schemes / domains in the host app.\n\n### Custom URL scheme (Expo)\n\nIn `app.json` / `app.config.ts`:\n\n```json\n{\n  \"expo\": {\n    \"scheme\": \"myscheme\"\n  }\n}\n```\n\nTest on iOS simulator:\n\n```bash\nxcrun simctl openurl booted \"myscheme://abc123?campaign=spring\"\n```\n\n### iOS Universal Links\n\n1. In the SmartLink admin, set App Linking / Team ID for your org.\n2. Ensure the redirect host serves `/.well-known/apple-app-site-association`.\n3. Add associated domains in the app, e.g. `applinks:go-smartlink.example.com`.\n\nExpo example:\n\n```js\nios: {\n  associatedDomains: ['applinks:go-smartlink.example.com'],\n}\n```\n\n### Android App Links\n\n1. Set SHA-256 cert fingerprint in SmartLink app-linking settings.\n2. Ensure the redirect host serves `/.well-known/assetlinks.json`.\n3. Add intent filters for your link host in the Android config / `AndroidManifest`.\n\n## Staging example URLs\n\nIf you use the project staging hosts:\n\n| Service | URL |\n|---------|-----|\n| Backend API | `https://api-smartlink.24livehost.com` |\n| Redirect / short links | `https://go-smartlink.24livehost.com` |\n\n```ts\ncreateDeeplinkSDK({\n  apiKey: 'your-key',\n  apiUrl: 'https://api-smartlink.24livehost.com',\n  redirectUrl: 'https://go-smartlink.24livehost.com',\n});\n```\n\n## API surface\n\n```ts\nimport {\n  createDeeplinkSDK,\n  DeeplinkSDK,\n  DeeplinkApiClient,\n  parseDeepLinkParams,\n  deepLinkParamsFromDeferred,\n  subscribeToDeepLinks,\n} from 'react-native-smartlink';\n\nimport type {\n  DeeplinkSDKConfig,\n  DeepLinkParams,\n  DeepLinkListener,\n  DeferredDeepLinkResult,\n  HealthResponse,\n  DeferredMatchRequest,\n  DeferredMatchResponse,\n} from 'react-native-smartlink';\n```\n\n## Troubleshooting\n\n| Problem | What to check |\n|---------|----------------|\n| Listener never fires | Scheme / associated domains / intent filters; try `simctl openurl` / `adb` with the same scheme |\n| Deferred match always `matched: false` | Redirect server deployed; recent click recorded; same network/IP as click when fingerprint is server-derived |\n| Health check fails | `apiUrl` / `redirectUrl` reachable from the device/emulator (not `localhost` on a physical device) |\n| TypeScript can’t resolve package | Restart TS server; ensure `node_modules/react-native-smartlink/dist` exists after install |\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-b2ab2a167458582aab5171600496b44c"}