Skip to content
EmitKitDocs
Esc
↑↓navigate↵open⌘Jpreview
On this page

Self-hosting

Run EmitKit on your own Cloudflare account: requirements, first deploy and updates.

You need a Cloudflare account on the Workers Paid plan (Queues and the CPU used by password hashing need it), a zone on Cloudflare DNS, and a HeroUI Pro licence to build the UI.

  1. Clone and install

    git clone https://github.com/emitkithq/emitkit-v3 && cd emitkit-v3
    npx heroui-pro@latest login     # or export HEROUI_AUTH_TOKEN=...
    pnpm install
  2. Create a deploy token with the permissions listed under Configuration, scoped to your account and zone.

  3. Configure .env.local (gitignored):

    CLOUDFLARE_API_TOKEN=...
    CLOUDFLARE_ACCOUNT_ID=...
    EMITKIT_DOMAIN=example.com
    # optional: EMITKIT_APP_HOST, EMITKIT_API_HOST, EMITKIT_SITE_HOST,
    # EMITKIT_REDIRECT_HOSTS, EMITKIT_EMAIL_FROM, EMITKIT_ALLOW_SIGNUP=false ...

    The chosen hostnames must not already have A/AAAA/CNAME records (a wildcard record is fine).

  4. Deploy

    pnpm build && pnpm exec alchemy deploy --stage prod --env-file .env.local --yes

    The first deploy creates Alchemy’s state store (a Worker in your account), the D1 database (and migrates it), the Analytics Engine dataset, the queue and consumer, the Email Sending subdomain with its DNS records, a read-only Analytics token, and the Worker with its custom domains and hourly cron. Later deploys use pnpm release, which refuses to run if that state has gone missing.

  5. Sign up at https://app.<domain> and follow the getting-started flow. To close sign-ups afterwards, set EMITKIT_ALLOW_SIGNUP=false and deploy again.

Variations

  • No Analytics Engine: set EVENT_STORE to d1 in alchemy.run.ts to keep events in D1 for 90 days. You can then drop the dataset and the analytics token.
  • Different product name or several installs per account: set EMITKIT_WORKER_NAME (and a different --stage) for each install.
  • No Workers AI: remove the AI binding. Emoji suggestions fall back to keyword matching.

Updating

git pull && pnpm install && pnpm release

Migrations are applied on deploy. Read the changelog and commit messages for anything that needs manual steps. Deployment covers deploying on every push, and Recovery covers backups and rollbacks.

Was this page helpful?