dub Documentation

The modern link attribution platform. Loved by world-class marketing teams like Framer, Perplexity, Superhuman, Twilio, Buffer and more.

24,313 stars TypeScript TypeScript 1 file Β· ~2,502 tokens #clickhouse#mysql#nextjs#open-source#planetscale#prisma#tailwindcss#tinybird
RAW Doc

Docker & Self-Hosted Deployment Verified OCI

Deploy dub on any server, homelab, or cloud container platform.

1-Click Terminal Command
bash (docker run)
docker run -d --name dub -p 3306:3306 --restart always mysql:8.0
Configured Services & Ports
βš™οΈ ps-mysql
image: mysql:8.0
πŸ”Œ Ports: 3306:3306
βš™οΈ planetscale-proxy
image: ghcr.io/mattrobenolt/ps-http-sim:latest
πŸ”Œ Ports: 3900:3900
βš™οΈ mailhog
image: mailhog/mailhog:latest
πŸ”Œ Ports: 1025:1025, 8025:8025
docker-compose.yml
yaml (docker-compose.yml)
# This is meant for local development only. Do not use this in production.
version: "3.8"

services:
  ps-mysql:
    image: mysql:8.0
    restart: always
    environment:
      MYSQL_DATABASE: planetscale
      MYSQL_ROOT_HOST: "%"
      MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
    command:
      [
        "--max_connections=1000",
        "--default-authentication-plugin=mysql_native_password",
      ]
    ports:
      - 3306:3306
    volumes:
      - ps-mysql:/var/lib/mysql

  planetscale-proxy:
    image: ghcr.io/mattrobenolt/ps-http-sim:latest
    command:
      [
        "-mysql-no-pass",
        "-listen-port=3900",
        "-mysql-dbname=planetscale",
        "-mysql-addr=ps-mysql",
      ]
    depends_on:
      - ps-mysql
    ports:
      - 3900:3900
    links:
      - ps-mysql

  mailhog:
    image: "mailhog/mailhog:latest"
    ports:
      - "1025:1025"
      - "8025:8025"

volumes:
  ps-mysql:

File: README.md

Dub

Introduction

Dub is the modern, open-source link attribution platform for short links, conversion tracking, and affiliate programs.

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.

Tech Stack

Self-Hosting

You can self-host Dub for greater control over your data and design. Read this guide to learn more.

Contributing

We love our contributors! Here's how you can contribute:

Package Version
node v23.11.0
pnpm 9.15.9

Common Local Development Issues

  • The table does not exist in the current database. - Run pnpm prisma:push push the state of the Prisma schema file to the database without using migrations files.
  • The project is not building correctly locally - verify your versions of node and pnpm match the recommended versions above. Delete all node_modules, .next, and .turbo directories in the apps and packages directory. You may now reinstall node_modules by running pnpm install and attempt to rebuild the project with pnpm build.

Dev Seed Script

This script seeds the database with development data for testing and development purposes.

Basic seeding (adds data without deleting existing data):

bash
cd apps/web
pnpm run script dev/seed

Truncate database before seeding (deletes all existing data first):

bash
cd apps/web
pnpm run script dev/seed --truncate

When using --truncate, the script will ask for confirmation before deleting any data.

Repo Activity

License

Dub Technologies, Inc. is a commercial open-source company, which means some parts of this open-source repository require a commercial license. The concept is called "Open Core" where the core technology (99%) is fully open source, licensed under AGPLv3 and the last 1% is covered under a commercial license ("/ee" Enterprise Edition) which we believe is entirely relevant for larger organisations that require enterprise features. Enterprise features are built by the core engineering team of Dub Technologies, Inc., which is hired full-time.


File: apps/web/app/(ee)/README.md

Enterprise Edition

Welcome to the Enterprise Edition of Dub.co.

The /(ee) subfolder is the place for all the Enterprise Edition features from our hosted plan and enterprise-grade features for Enterprise, included but not limited to the following:

❗ WARNING: This repository is copyrighted (unlike our main repo). You are not allowed to use this code to host your own version of app.dub.co without obtaining a proper license first❗


File: packages/utils/README.md

`@dub/utils`

@dub/utils is a library of utility functions that are used across Dub's web applications.

Installation

To install the package, run:

bash
pnpm i @dub/utils

File: packages/ui/src/icons/nucleo/README.md

Nucleo Icons

❗ These icons are copyrighted and redistribution is prohibited. See the full Nucleo copyright notice below.

Copyright Β© Nucleo

Version 1.3, January 3, 2024

Nucleo Icons

https://nucleoapp.com/

  • Redistribution of icons is prohibited.
  • Icons are restricted for use only within the product they are bundled with.

For more details:

https://nucleoapp.com/license


File: packages/ui/README.md

`@dub/ui`

@dub/ui is a library of React components that are used across Dub's web applications.

Installation

To install the package, run:

bash
pnpm i @dub/ui

File: packages/tinybird/README.md

Dub Tinybird Setup

bash
β”œβ”€β”€ datasources
β”‚   └── dub_click_events.datasource
β”‚   └── dub_click_events_mv.datasource
β”‚   └── dub_links_metadata.datasource
β”‚   └── dub_links_metadata_latest.datasource
β”œβ”€β”€ endpoints
β”‚   β”œβ”€β”€ browser.pipe
β”‚   β”œβ”€β”€ city.pipe
β”‚   β”œβ”€β”€ clicks.pipe
β”‚   β”œβ”€β”€ country.pipe
β”‚   β”œβ”€β”€ device.pipe
β”‚   β”œβ”€β”€ os.pipe
β”‚   └── referer.pipe
β”‚   └── timeseries.pipe
β”‚   └── top_links.pipe
β”‚   └── top_urls.pipe
β”œβ”€β”€ pipes
β”‚   β”œβ”€β”€ dub_click_events_pipe.pipe
β”‚   β”œβ”€β”€ dub_links_metadata_pipe.pipe

File: packages/stripe-app/README.md

Stripe App

This is the Stripe app for Dub Conversions.

Publish new version

  1. Run stripe login in your terminal and sign in to Dub Technologies, Inc..
  2. Navigate to the packages/stripe-app directory.
  3. Increment the version field in stripe-app.json.
  4. Upload the updated app using stripe apps upload.
  5. Publish the new version via the Stripe dashboard.

Run locally

text
stripe apps start

File: packages/embeds/react/README.md

`@dub/embed-react`

@dub/embed-react is a library of React components that are used embed Dub's referral dashboard on third-party websites.

Installation

To install the package, run:

bash
pnpm i @dub/embed-react

File: packages/embeds/core/README.md

`@dub/embed-core`

@dub/embed-core is a library that contains the core logic for embedding Dub's referral dashboard on third-party websites.

Installation

To install the package, run:

bash
pnpm i @dub/embed-core

File: packages/cli/README.md

`dub-cli`

A CLI for easily shortening URLs with the Dub API.

https://github.com/user-attachments/assets/2ce9fe51-68ab-4e6d-b08d-4da09c17f90e

Available Commands

Command Description
dub login Log into the DUB platform
dub config See your configured workspace credentials
dub domains Configure your workspace domain
dub shorten [url] [key] Create a short link. You can preemptively pass the URL and the generated short link key, or go through the CLI prompts.
dub links [options] Search for links in your Dub workspace. Available options include: -s, --search <search> to search for a link by name, or -l, --limit <limit> to limit the number of links returned (default is 10).
dub help [command] Display help for a specific command

Running Locally for Development

  1. Clone the repository, install dependencies and navigate to the cli folder:
    bash
    cd packages/cli
  2. Build the package in watch mode:
    bash
    pnpm dev
  3. In a separate terminal, navigate to the cli folder again and run an available command:
    bash
    pnpm start [command]
  4. See all available commands and options:
    bash
    pnpm start help

Testing Production-like Setup

Warning
If you have previously installed dub-cli globally, uninstall it first to avoid conflicts

  1. Clone the repository, install dependencies and navigate to the cli folder:
    bash
    cd packages/cli
  2. Build the package:
    bash
    pnpm build
  3. Link the package globally:
    bash
    npm link
  4. Verify the installation:
    bash
    dub -v
  5. Run commands:
    bash
    dub [command]