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/baxlinks

Requires 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

OptionRequiredDescription
projectIdYesBaxCloud project ID
apiKeyYesAPI key with Links enabled
timeoutNoRequest timeout in ms (default 30000)
debugNoLog requests to console

API Methods

MethodDescription
createLinkCreate a deep link
listLinksList links with pagination
getLinkGet link by ID
updateLinkUpdate a link
deleteLinkDelete a link
getStatsProject-wide stats
getAnalyticsClick analytics for a link
getTimelineClick timeline
uploadImageUpload 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