BaxLinks/Node.js SDK
Node.js SDK
Server-side deep link creation and analytics for Express, NestJS, Next.js API routes, and any Node.js backend
Installation
npm install @baxcloud/baxlinks
# or
pnpm add @baxcloud/baxlinksRequires Node.js 18+. Use alongside mobile SDKs (Flutter, React Native, Swift, Kotlin) for deferred deep linking in apps.
Quick Start
1import { BaxCloudLinksClient } from '@baxcloud/baxlinks';
2
3const links = new BaxCloudLinksClient({
4 projectId: process.env.BAXCLOUD_PROJECT_ID!,
5 apiKey: process.env.BAXCLOUD_API_KEY!,
6});
7
8const link = await links.createLink({
9 fallbackUrl: 'https://myapp.com/product/123',
10 deepLinkPath: '/product/123',
11 deepLinkParams: { promo: 'summer' },
12 title: 'Summer Sale',
13 alias: 'summer-sale',
14});
15
16console.log('Slug:', link.slug);Backend + mobile pattern
Create links from your server (referrals, campaigns, share URLs). Mobile apps use BaxLinks SDKs to handle deferred deep linking when users open the short link.
1// POST /api/referral-link — your API creates the link
2app.post('/api/referral-link', async (req, res) => {
3 const link = await links.createLink({
4 fallbackUrl: 'https://myapp.com/signup',
5 deepLinkPath: '/signup',
6 deepLinkParams: { ref: req.user.id },
7 alias: `ref-${req.user.id}`,
8 });
9 res.json({ slug: link.slug });
10});Configuration
| Option | Required | Description |
|---|---|---|
| projectId | Yes | BaxCloud project ID |
| apiKey | Yes | API key with Links enabled |
| timeout | No | Request timeout in ms (default 30000) |
| debug | No | Log requests to console |
API Methods
| Method | Description |
|---|---|
| createLink | Create a deep link |
| listLinks | List links with pagination |
| getLink | Get link by ID |
| updateLink | Update a link |
| deleteLink | Delete a link |
| getStats | Project-wide stats |
| getAnalytics | Click analytics for a link |
| getTimeline | Click timeline |
| uploadImage | Upload OG preview image |
Error handling
1import { BaxLinksError } from '@baxcloud/baxlinks';
2
3try {
4 await links.createLink({ fallbackUrl: 'https://example.com' });
5} catch (err) {
6 if (err instanceof BaxLinksError) {
7 console.error(err.statusCode, err.code, err.message);
8 }
9}Mobile SDKs: Flutter · React Native · Swift · Kotlin