@rajeev02/deeplink 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +124 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# @rajeev02/deeplink
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@rajeev02/deeplink)
|
|
4
|
+
[](https://github.com/Rajeev02/rajeev-sdk/blob/main/LICENSE)
|
|
5
|
+
|
|
6
|
+
**Universal deep linking** with pattern matching, param extraction, UTM attribution, and deferred deep links — includes 19 pre-built super-app routes.
|
|
7
|
+
|
|
8
|
+
Part of [Rajeev SDK](https://github.com/Rajeev02/rajeev-sdk) — cross-platform infrastructure libraries for building apps that work everywhere.
|
|
9
|
+
|
|
10
|
+
## Why use this?
|
|
11
|
+
|
|
12
|
+
- **Route matching** — URL pattern matching with `:param` extraction, query string parsing
|
|
13
|
+
- **19 pre-built routes** — Common super-app screens (product, cart, checkout, order tracking, profile, chat, etc.)
|
|
14
|
+
- **UTM attribution** — Automatic UTM parameter extraction and analytics callback
|
|
15
|
+
- **Deferred deep links** — Handle links that arrive before the app is ready (cold start)
|
|
16
|
+
- **Universal + App links** — Generate both `myapp://` scheme links and `https://` universal links
|
|
17
|
+
- **Pure TypeScript** — No native link handling dependency. Plug into React Navigation or any router.
|
|
18
|
+
|
|
19
|
+
## Platform Support
|
|
20
|
+
|
|
21
|
+
| Platform | Engine | Status |
|
|
22
|
+
| ---------- | ---------- | ------ |
|
|
23
|
+
| iOS 16+ | TypeScript | ✅ |
|
|
24
|
+
| Android 7+ | TypeScript | ✅ |
|
|
25
|
+
| Web | TypeScript | ✅ |
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install @rajeev02/deeplink
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Peer Dependencies
|
|
34
|
+
|
|
35
|
+
- `react` >= 18.3.0
|
|
36
|
+
- `react-native` >= 0.84.0 _(optional)_
|
|
37
|
+
|
|
38
|
+
## Quick Start
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import { DeepLinkRouter, getCommonRoutes } from "@rajeev02/deeplink";
|
|
42
|
+
|
|
43
|
+
// Create router with 19 pre-built routes
|
|
44
|
+
const router = new DeepLinkRouter({
|
|
45
|
+
scheme: "myapp://",
|
|
46
|
+
domains: ["myapp.com", "myapp.page.link"],
|
|
47
|
+
routes: getCommonRoutes(),
|
|
48
|
+
onNoMatch: (url) => console.warn("No route for:", url),
|
|
49
|
+
onAttribution: (data) => analytics.track("deeplink", data),
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Mark app ready (processes any deferred links from cold start)
|
|
53
|
+
router.setReady();
|
|
54
|
+
|
|
55
|
+
// Handle incoming URL
|
|
56
|
+
const match = router.handle("myapp://product/123?utm_source=email");
|
|
57
|
+
if (match) {
|
|
58
|
+
console.log(match.route.screen); // → "ProductScreen"
|
|
59
|
+
console.log(match.params.id); // → "123"
|
|
60
|
+
console.log(match.query); // → { utm_source: "email" }
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Generate links
|
|
64
|
+
const appLink = router.generate("/product/:id", { id: "456" });
|
|
65
|
+
// → "myapp://product/456"
|
|
66
|
+
|
|
67
|
+
const webLink = router.generateUniversalLink("/product/:id", { id: "456" });
|
|
68
|
+
// → "https://myapp.com/product/456"
|
|
69
|
+
|
|
70
|
+
// Add custom routes
|
|
71
|
+
router.addRoute({
|
|
72
|
+
pattern: "/store/:storeId/menu",
|
|
73
|
+
screen: "StoreMenuScreen",
|
|
74
|
+
authRequired: false,
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Pre-Built Routes
|
|
79
|
+
|
|
80
|
+
`getCommonRoutes()` returns 19 routes for common super-app screens:
|
|
81
|
+
|
|
82
|
+
| Pattern | Screen | Auth |
|
|
83
|
+
| ------------------------ | ------------------- | ---- |
|
|
84
|
+
| `/home` | HomeScreen | No |
|
|
85
|
+
| `/product/:id` | ProductScreen | No |
|
|
86
|
+
| `/category/:id` | CategoryScreen | No |
|
|
87
|
+
| `/search` | SearchScreen | No |
|
|
88
|
+
| `/cart` | CartScreen | Yes |
|
|
89
|
+
| `/checkout` | CheckoutScreen | Yes |
|
|
90
|
+
| `/order/:orderId` | OrderDetailScreen | Yes |
|
|
91
|
+
| `/order/:orderId/track` | OrderTrackScreen | Yes |
|
|
92
|
+
| `/payment/:txnId/status` | PaymentStatusScreen | Yes |
|
|
93
|
+
| `/profile` | ProfileScreen | Yes |
|
|
94
|
+
| `/profile/edit` | EditProfileScreen | Yes |
|
|
95
|
+
| `/settings` | SettingsScreen | Yes |
|
|
96
|
+
| `/chat/:roomId` | ChatScreen | Yes |
|
|
97
|
+
| `/offer/:offerId` | OfferScreen | No |
|
|
98
|
+
| `/refer` | ReferralScreen | Yes |
|
|
99
|
+
| `/scan` | ScanScreen | Yes |
|
|
100
|
+
| `/pay/:vpa` | PayScreen | Yes |
|
|
101
|
+
| `/kyc` | KycScreen | Yes |
|
|
102
|
+
| `/support` | SupportScreen | No |
|
|
103
|
+
|
|
104
|
+
## API Reference
|
|
105
|
+
|
|
106
|
+
### `DeepLinkRouter`
|
|
107
|
+
|
|
108
|
+
| Method | Returns | Description |
|
|
109
|
+
| ----------------------------------------- | -------------------------- | ------------------------- |
|
|
110
|
+
| `handle(url)` | `DeepLinkMatch \| null` | Match URL, extract params |
|
|
111
|
+
| `generate(pattern, params?)` | `string` | Generate app-scheme link |
|
|
112
|
+
| `generateUniversalLink(pattern, params?)` | `string` | Generate HTTPS link |
|
|
113
|
+
| `setReady()` | `void` | Process deferred links |
|
|
114
|
+
| `getDeferredLink()` | `DeferredDeepLink \| null` | Get cold-start link |
|
|
115
|
+
| `addRoute(route)` | `void` | Register a route |
|
|
116
|
+
| `getRoutes()` | `DeepLinkRoute[]` | List all routes |
|
|
117
|
+
|
|
118
|
+
## Full Documentation
|
|
119
|
+
|
|
120
|
+
📖 [Complete API docs with types and configuration](https://github.com/Rajeev02/rajeev-sdk/blob/main/docs/usage/DEEPLINK.md)
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
MIT © 2026 [Rajeev Kumar Joshi](https://rajeev02.github.io)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rajeev02/deeplink",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Universal deep linking — app links, universal links, deferred deep links, route matching, attribution",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"author": "Rajeev Kumar Joshi <rajeevjoshi91@gmail.com> (https://rajeev02.github.io)",
|