Dub
Open-source link management and attribution platform for modern teams
Why consider Dub?
Dub is an open-source link attribution platform designed for marketing and engineering teams. It provides link shortening, detailed conversion analytics, and affiliate management tools.
Learn Dub by building
Practical setup notes, real use cases, and copy-ready examples in one focused guide.
In this guide4 sections
Overview of Dub and Core Capabilities
Dub is the modern, open-source link attribution platform for short links, conversion tracking, and affiliate programs. Modern marketing, growth, and engineering teams require unified visibility into how shared URLs perform across multiple channels, campaigns, and referral networks. Dub solves this attribution challenge by consolidating short link generation, detailed conversion analysis, and partner referral management into a single open infrastructure layer.
The platform is architected to handle massive production scale without sacrificing low-latency link resolution. Our platform powers 100M+ clicks and 2M+ links monthly, and is used by world-class marketing teams from companies like Twilio, Buffer, Framer, Perplexity, Vercel, Laravel, and more. By unifying link redirection with clickstream telemetry, marketing teams can discover top-performing channels while maintaining full attribution integrity across public links and partner programs.
For organizations requiring total data governance, complete custom branding, and private network deployment, you can self-host Dub on your own servers and cloud infrastructure for greater control over your data and design. Running a self-hosted instance ensures that sensitive click events, affiliate tracking metadata, and customer engagement metrics remain entirely within your own cloud boundary.
Repository Setup and Initial Configuration
To begin setting up a self-hosted instance, clone the source code from the official GitHub repository onto your local development environment or build server. First, clone the Dub repo into a public GitHub repository. If you are planning to distribute the code or allow users to interact with the code remotely (e.g., as part of a hosted application), make sure to provide source access (including modifications) as required by the AGPLv3 license.
git clone https://github.com/dubinc/dub.gitNavigate into the project directory and install the project dependencies with pnpm:
pnpm iOnce dependencies are installed, prepare the configuration files for self-hosting. In standalone deployments that do not rely on scheduled cloud functions, delete the apps/web/vercel.json file since cron jobs are not required for the self-hosted version. This ensures your local build does not attempt to register serverless cron handlers intended solely for the hosted service.
Infrastructure and Database Architecture
Dub leverages a high-performance multi-database architecture tailored for low latency and analytics efficiency. Next, you'll need to set up the Tinybird Clickhouse database. This will be used to store time-series click events data. Tinybird's ClickHouse foundation allows the system to ingest and aggregate millions of click events in real time, powering interactive filtering and geographic telemetry in the admin dashboard.
Fast URL resolution and edge redirect execution are backed by an in-memory caching tier. Next, you'll need to set up the Upstash Redis database. This will be used to cache link metadata and serve link redirects. By caching active short link definitions in Redis, incoming web requests are routed immediately to their destination targets with minimal latency overhead.
Core relational data, including user accounts, team workspaces, domain associations, and link configurations, is maintained in a MySQL-compatible database. Next, you'll need to set up a PlanetScale-compatible MySQL database. This will be used to store user data and link metadata.
Generate the Prisma client code and push database schemas:
pnpm run prisma:generatepnpm run prisma:pushStorage, Email, and Licensing
In addition to database storage, media assets such as custom social sharing cards, user avatars, and workspace logos require object storage. Dub stores user-generated assets in either S3 or S3-compatible services like Cloudflare R2. Configuring an S3-compatible bucket allows uploaded images and generated link preview assets to be delivered reliably over a content delivery network.
User authentication and system notifications rely on transactional email delivery. Next, you'll need to set up Resend for transactional emails (e.g. magic link emails). Providing a valid email API key allows the self-hosted instance to securely dispatch login links, invite teammates, and send system alerts.
From a software licensing standpoint, content outside of the above mentioned directories or restrictions above is available under the AGPLv3 license. The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software. This licensing model ensures that the open-source community benefits from enhancements made to the network software.
By combining link attribution, conversion analytics, and affiliate management, Dub helps businesses turn clicks into revenue. For more information, visit the Dub repository and check the Dub releases for the latest project updates.
Related tools
More options with a similar category or technology profile.
diskus
Minimal, fast alternative to du -sh written in Rust using multi-threaded directory traversal.
peco
Simplistic interactive filtering tool for Unix pipelines, process lists, and file trees.
Dapr CLI
Command-line tool for managing Dapr distributed application runtime environments and sidecars.
Freeze
Generate beautiful image screenshots and SVGs of code snippets and terminal outputs.