Dub
The open-source link attribution platform for short links, conversion tracking, and affiliate programs — powering 100M+ clicks monthly.
Dub is a modern, open-source link attribution platform built for marketing teams that need precise control over short links, real-time conversion tracking, and affiliate program management in a single unified system. It solves the fragmentation problem in link management by connecting the full journey from link click to downstream sale, with identity-aware attribution that persists across sessions.
Used by world-class engineering and marketing teams at Twilio, Buffer, Framer, Perplexity, Vercel, and Laravel, Dub handles over 100 million clicks and 2 million links monthly. It replaces point solutions like Bitly for short links, separate analytics platforms, and standalone affiliate tools with one integrated system built on modern open-source infrastructure.
The platform is designed for self-hosting with full data ownership, and provides an Open Core architecture where the 99% open-source AGPLv3 core handles link management, analytics, and API access, while enterprise features like SAML SSO, conversion tracking, and affiliate payouts are available under a commercial license. Teams can run Dub on their own infrastructure or use the hosted dub.co service.
Beyond the web app, Dub ships publishable npm packages — @dub/ui for its design system, @dub/utils for shared utilities, @dub/embed-react for embedding referral programs, and @dub/cli — making the platform extensible for developers building on top of its primitives.
What You Get
- Branded short links with custom domains - Create short links on your own custom domains (e.g., acme.link) with support for custom OG previews, password protection, link expiration, and DNS verification via A/CNAME records.
- Real-time conversion analytics - Track the full attribution journey from link click through lead capture to completed sale, with visual dashboards showing sources, geographies, devices, and conversion funnels powered by Tinybird.
- Affiliate program management - Run native affiliate programs with a dedicated partner portal, unique referral link generation, automated revenue tracking, fraud detection, and configurable payout rules tied to verified conversions.
- Device and geo targeting - Route users to different destination URLs based on detected device type (iOS, Android, desktop) or geographic location, with fallback URLs for unmatched segments.
- QR code generation - Automatically generate branded QR codes for every short link with customizable logos, colors, and download formats suitable for print and digital campaigns.
- Deep link support - Detect and handle iOS App Store URLs, Google Play Store URLs, AppsFlyer tracking URLs, custom URI schemes, and Singular tracking links natively within the redirect middleware.
- Embeddable referral widgets - Use the
@dub/embed-reactpackage to embed a white-label referral program directly in your app UI, allowing users to generate and share referral links without leaving your product. - Webhook and API integrations - Trigger external actions via webhooks on link clicks, lead captures, and commission payouts, with a typed REST API and OpenAPI spec for programmatic link management.
Common Use Cases
- Running a SaaS referral program - A B2B SaaS company embeds Dub’s referral widget using
@dub/embed-react, lets customers generate referral links from within their dashboard, and automatically tracks which referrals convert to paid accounts with commission payout automation. - Tracking multi-channel marketing attribution - A marketing team creates UTM-tagged short links for each campaign channel, uses Dub’s conversion events API to record signups and purchases, and analyzes the full attribution funnel from first click to revenue in the analytics dashboard.
- Self-hosting a branded link shortener - An enterprise team deploys Dub on their own infrastructure to maintain full data ownership, connects their corporate domain for branded short links, and restricts access using role-based workspace controls.
- Managing partner payouts for an affiliate network - An e-commerce platform uses Dub Partners to onboard affiliate marketers, issue unique tracking links, verify conversions against orders, detect fraudulent activity, and automate monthly commission payouts.
- Deep linking in mobile campaigns - A mobile app publisher creates short links that automatically route iOS users to the App Store, Android users to the Play Store, and desktop visitors to the website, with click analytics segmented by platform.
- White-labeling short links for agency clients - A digital agency uses Dub’s multi-workspace architecture and custom domain support to manage branded link campaigns for multiple clients under separate workspaces with isolated analytics.
Under The Hood
Architecture
Dub is structured as a turborepo monorepo with clear domain boundaries: a primary Next.js application in apps/web and shared publishable packages for the UI design system, utilities, email rendering, embed components, and a CLI. The Next.js app employs a multi-tenant hostname routing strategy via Edge middleware that dispatches requests to specialized handlers based on hostname matching, simultaneously serving a dashboard app, REST API, link redirection, and a partners portal. Link resolution is a particular architectural achievement — incoming requests to any custom domain are handled at the Vercel Edge by resolving the domain, looking up the cached link in Upstash Redis, and performing the redirect before a serverless function spins up. The Enterprise Edition is architecturally isolated under (ee) Next.js route groups with a separate commercial license, forming a principled Open Core boundary. Prisma handles relational data on PlanetScale, Upstash Redis caches hot links for sub-10ms redirects, and Tinybird handles high-volume analytics event streaming.
Tech Stack The application is built on Next.js 15 with React 19 and TypeScript throughout the monorepo, with Turbo orchestrating builds. Prisma ORM with the PlanetScale adapter provides type-safe access to a serverless MySQL-compatible database. Upstash Redis serves the link resolution cache, enabling edge-speed redirects. Tinybird provides columnar analytics for real-time aggregation of click, lead, and sale events. NextAuth.js handles authentication, with BoxyHQ providing SAML SSO and SCIM directory sync for enterprise customers. Stripe processes subscription billing and partner commission payouts. Resend handles transactional email. Axiom provides structured observability with middleware request logging. AI capabilities are added via the Vercel AI SDK with an Anthropic backend, and Firecrawl handles web content extraction for AI-assisted features.
Code Quality
Testing is comprehensive across two frameworks: Vitest for integration and API tests covering domains, links, analytics, customers, fraud, payouts, tags, and more, and Playwright for end-to-end browser tests. A custom IntegrationHarness class abstracts workspace setup, authentication, and HTTP client creation, enabling consistent and DRY test setup across extensive test suites. Zod is used pervasively for schema validation at API boundaries, providing runtime type safety that complements TypeScript’s compile-time checks. Error handling uses HTTP status codes with structured JSON responses throughout API routes. TypeScript strict mode is enforced monorepo-wide, and Prettier with the Tailwind CSS plugin handles formatting. The codebase reflects a mature engineering culture with named abstractions, consistent conventions, and layered separation between edge routing, data access, and business logic.
What Makes It Unique
Dub’s most technically distinctive capability is closing the attribution loop between a short link click and a downstream sale using persistent identity hashing across sessions — a capability that most link shorteners don’t attempt. The native affiliate and partner program, built with its own portal, fraud detection, embed tokens for white-label referral widgets, and payout automation, is assembled from first principles rather than bolted on from a third-party SDK. The deep link handling inside the redirect middleware — detecting iOS App Store, Google Play Store, AppsFlyer, Singular tracking URLs, and custom URI schemes — is operationally sophisticated. The platform also ships consumer-grade npm packages (@dub/ui, @dub/embed-react) that make it genuinely extensible as an infrastructure layer rather than just a standalone SaaS product.
Self-Hosting
Dub uses an Open Core licensing model. The core application — approximately 99% of the codebase — is licensed under AGPLv3, which is a strong copyleft license. This means you can use, modify, and self-host Dub freely for personal, internal, or commercial purposes, but if you run a modified version over a network and make it publicly accessible, you are required to release your modifications under the same AGPLv3 terms. If you are running it strictly internally (not offering it as a service to outside users), the copyleft network provision does not apply. The enterprise features under the (ee) directory are covered by a separate commercial license from Dub Technologies, Inc., which explicitly prohibits running those features in production without a valid commercial subscription — though you may use them for development and testing.
Operationally, self-hosting Dub requires a non-trivial infrastructure footprint. You will need to provision and maintain a PlanetScale-compatible MySQL database (or another Prisma-compatible database with some configuration), Upstash Redis for the link resolution cache, a Tinybird account or compatible ClickHouse-based analytics backend for click event streaming, a Resend account for transactional email, and Vercel (or a compatible Node.js hosting platform) for the Next.js application. Environment variable configuration is extensive, and the self-hosting guide covers the essentials, but ongoing operational responsibility for uptime, database backups, schema migrations, and dependency upgrades falls entirely on your team.
Compared to the managed dub.co hosted service, self-hosters give up several enterprise-grade conveniences: managed upgrades, 99.9%+ SLA guarantees, Dub’s support team, and the full conversion tracking and partner affiliate features (which require an Enterprise license). The hosted service also provides a CDN-optimized global redirect network out of the box that takes significant effort to replicate on self-managed infrastructure. Teams evaluating self-hosting should weigh the data ownership and customization benefits against the engineering overhead of maintaining the full external service dependency chain.
Related Apps
OpenBB
Databases · Analytics · Invoicing Finance
The AI Workspace for Finance: Connect Data, Run AI Agents, Build Analytics
OpenBB
OtherMetabase
Analytics
The open-source BI platform that lets anyone ask questions and build dashboards without writing SQL — with an embedded analytics SDK and AI-powered query assistant included.
Metabase
OtherClickHouse
Databases · Analytics · Data Engineering
Open-source column-oriented database that delivers real-time analytical queries on petabyte-scale data with millisecond latency.