# Host it yourself

Run your own Drop on Cloudflare, Vercel, Netlify, Deno Deploy, or a VPS.

[Deploy to Cloudflare](https://deploy.workers.cloudflare.com/?url=https%3A%2F%2Fgithub.com%2Fvite-hub%2Fdrop) [Deploy to Vercel](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fvite-hub%2Fdrop&env=GITHUB_CLIENT_ID%2CGITHUB_CLIENT_SECRET%2CBETTER_AUTH_SECRET%2CDROP_ADMINS%2CCLOUDFLARE_ACCOUNT_ID%2CCLOUDFLARE_API_TOKEN%2CCLOUDFLARE_D1_DATABASE_ID%2CCLOUDFLARE_D1_DATABASE_NAME&envDescription=GitHub+sign-in%2C+admin+emails%2C+Cloudflare+D1%2C+and+a+private+Blob+store.+See+the+Drop+guide+for+each+value.&envLink=https%3A%2F%2Fdrop.vitehub.dev%2Fdocs%2Fself-host%2Fvercel&stores=%5B%7B%22type%22%3A%22blob%22%7D%5D) [Deploy to Netlify](https://app.netlify.com/start/deploy?repository=https%3A%2F%2Fgithub.com%2Fvite-hub%2Fdrop) [Deploy to Deno Deploy](https://console.deno.com/new?clone=https%3A%2F%2Fgithub.com%2Fvite-hub%2Fdrop) [Run on a VPS](https://drop.vitehub.dev/docs/self-host/vps#steps)

Start with the button for your host. You still supply GitHub sign-in and your admin email; the sections below cover those and the database. Each host page lists where its settings go.

## License

**Running Drop is free for one or two people**, and trying it out is free at any size. A team of 3 or more needs a license, $9 per member a month; [Pricing](https://drop.vitehub.dev/pricing) says who counts and how to buy one. Running Drop as a hosted service for others needs a license at any size. The Business Source License has the terms.

## Sign-in and admins

Drop signs in with **GitHub**. Create a GitHub OAuth app with:

- **Homepage URL**: `https://<your-domain>`
- **Authorization callback URL**: `https://<your-domain>/api/auth/callback/github`

Then set these on the deployment:

| Variable | What it is |
| --- | --- |
| GITHUB\_CLIENT\_ID | Your GitHub OAuth app's client ID. |
| GITHUB\_CLIENT\_SECRET | A client secret from the same app. |
| BETTER\_AUTH\_SECRET | Signs sessions and agent tokens. One per deployment: openssl rand -base64 32 |
| DROP\_ADMINS | Admin emails, comma-separated. Whoever signs in with one of them is Admin. |
| VITEHUB\_WEBHOOKS\_KEY | Seals each member's agent for Send, the URL and its secret: openssl rand -base64 32. A new key disconnects every agent. |
| VITEHUB\_MEMBERS | Optional. Only these people (and the admins) sign in, open shared links, and use MCP: github:\<id>, verified emails, @domains, or github-org:\<org>, comma-separated. |
| DROP\_MODE | Optional. team for a Drop one team runs: everyone signed in is a teammate, and new drops start shared with the Team. Defaults to personal. |
| DROP\_PUBLIC\_LINK\_DAYS | Optional. Days a public link stays open. Empty: 7 on a team Drop, no limit on a personal one. 0 turns public links off. |

Drop reads its settings when it runs, so a change needs a restart, not a rebuild. Only the host and database are fixed at build time. Each setting also answers to a `VITEHUB_` name, such as `VITEHUB_DROP_MODE`, which wins when both are set. `VITEHUB_MEMBERS` is owned by ViteHub Auth and only reads that name; `VITEHUB_DROP_MEMBERS` is unsupported. Booleans take `true`, `false`, `1`, or `0`; an invalid value stops Drop with an error naming the setting.

- **Who signs in.** Anyone with a GitHub account, as a Member. `VITEHUB_MEMBERS` lets in only the people it lists, plus the admins, for publishing and viewing, shared links and MCP included. Each entry is a GitHub account ( `github:22072217`), an email a sign-in method verified, an email domain ( `@example.com`), or a GitHub organization ( `github-org:your-org`), which makes sign-in ask for `read:org`. Matching any entry is enough. Take someone off, and they can't sign in again and lose their session within five minutes. It's ViteHub Auth's member list.
- **Who is Admin.** `DROP_ADMINS` lists admin emails, separated by commas or spaces, in any case. Whoever signs in with one, by a method that verified the email, is Admin. Restart to apply a change. In `nuxt dev` and with `DROP_TEST_SIGNIN`, an unverified email counts too.
- **Roles come only from that list.** Admins open **Console** in the sidebar, which opens this Drop in the ViteHub Console, to ban and unban users, revoke sessions, and change plans when `DROP_QUOTAS` is on. Link the Drop there once and set the `VITEHUB_CONSOLE_KEY_<NAME>` variable it shows; the Console then lets in only people whose email is in `DROP_ADMINS`. On Node/VPS, build with `DROP_PUBLIC_URL=https://drop.example.com`; signed calls require this trusted origin at build time. For Docker, build your deployment image with `docker build --build-arg DROP_PUBLIC_URL=https://drop.example.com -t my-drop .` instead of using the generic prebuilt image for Console access. Rebuild when the public origin changes. The ingress must pass `POST /_vitehub/rpc` and its subpaths unchanged. Roles are read-only and impersonation is disabled. Admins can find **Review shares** and **Reports** through Search.
- **Other sign-in.** Change the Better Auth options in `server/auth.ts`, or [reuse an existing GitHub oauth2-proxy](https://drop.vitehub.dev/docs/self-host/vps.md#auth-proxy).

| Role | What they can do |
| --- | --- |
| Admin | Everything, plus members, settings, and the team's folders. |
| Member | Create, share, and comment on drops, and add to the team's folders. |

## Team mode

A Drop is **personal** by default, like drop.vitehub.dev: drops start Only me, and people share them by public link. `DROP_MODE=team` makes it a Drop one team runs for itself, usually behind `VITEHUB_MEMBERS` or [oauth2-proxy](https://drop.vitehub.dev/docs/self-host/vps.md#auth-proxy). Everyone signed in is then a teammate:

- New drops start shared with the Team.
- The sidebar leads with the **Team** tab: the team's folders, then teammates' drops shared with the team.
- Admins create team folders, with **New › Folder** and the team's folder switch, or **New team folder** on an empty Team tab, and write their descriptions. Everyone adds drops to them. [Team folders](https://drop.vitehub.dev/docs/review.md#folders) has the rules.

`DROP_PUBLIC_LINK_DAYS` sets how many days a public link stays open. Left empty, it's 7 on a team Drop and no limit on a personal one; `0` turns public links off. A closed link falls back to Team, or to Only me on a personal Drop. This is separate from a drop's lifetime.

```
DROP_MODE=team
DROP_ADMINS=you@example.com
VITEHUB_MEMBERS=github-org:your-org
DROP_PUBLIC_LINK_DAYS=7
```

## Teams on a personal Drop

`DROP_TEAMS=true` lets people on a personal Drop make teams on **Teams**. A team works like a small team Drop inside yours: its owner and admins invite people by email and make its folders, and drops in those folders reach its members and their agents, nobody else. Drop sends no email, so whoever invites copies the link and sends it; the invitee joins by opening it, signed in with that email.

Deleting an account takes it off its teams, and Stripe bills each team one seat less, including while a payment is past due. A team the account owned passes to its oldest admin, or to its oldest member when it has no admin. A team with nobody else on it is permanently deleted with its folders and their contents, files, and comments, but not while it still pays: cancel its subscription first.

Past-due Stripe seat updates finish for every team before any memberships, ownership, or team content change. If a later update or local cleanup fails, Drop restores the attempted Stripe seat changes before rejecting the deletion. Memberships, ownership, and local seat counts commit together, so the account keeps all its teams on failure; retry the deletion once the service recovers. An error that also reports a failed Stripe restoration needs its team quantities checked in Stripe before retrying.

| Variable | What it does |
| --- | --- |
| DROP\_TEAMS | Set true to turn teams on. Ignored on a team Drop, which is one team already. |
| DROP\_FREE\_TEAM\_MEMBERS | Members a team has before it needs a subscription, invitations included. Defaults to 2. Applies only with billing on. |
| DROP\_FREE\_KEPT | Drops the Free plan keeps forever at once. Defaults to 10. Applies only with `DROP_QUOTAS=true`. |

### Bill teams through Stripe

With billing on, a team past its free members needs the Team plan: one seat per member, kept in step with Stripe as people join and leave, with a 14-day trial. Everyone on a team that pays gets the Pro plan. `/pricing` then shows the Team plan below the license prices. When Stripe can't charge a team's card, the team is on the Free plan until payment succeeds, including after Stripe stops retrying. Its page asks its owner and admins to update the card in Stripe's billing portal instead of starting a second subscription.

| Variable | What it does |
| --- | --- |
| STRIPE\_SECRET\_KEY | Your Stripe secret key. |
| STRIPE\_WEBHOOK\_SECRET | The signing secret of a webhook to `<origin>/api/auth/stripe/webhook` that sends `checkout.session.completed` and the `customer.subscription.*` events. |
| STRIPE\_TEAM\_PRICE\_ID | A recurring per-unit price for one member. |
| STRIPE\_TEAM\_ANNUAL\_PRICE\_ID | Optional: its yearly price, which adds a Pay yearly button. |
| STRIPE\_MANAGED\_PAYMENTS | Defaults to true: Stripe sells as merchant of record and files sales tax and VAT. Turn Managed Payments on in Stripe and give the product an eligible tax code. Set false to sell under your own account. |

Billing turns on once teams are on and the key, the webhook secret, and the price are all set.

## Give apps their own domain

Apps and HTML docs run their own scripts, so by default Drop shows them in a sandbox with no origin, away from Drop and the reader's session. The sandbox also blocks `localStorage`, cookies, and URL changes. Drop swaps in temporary storage, but an app that routes by its URL breaks.

Set `DROP_CONTENT_ORIGIN` to a wildcard such as `https://*.drop-usercontent.example.com`, and serve every hostname under it from the same deployment. Each drop then runs on its own subdomain, as on a static host: storage and history work, and one app can't read what another stored. The subdomain is a hash of the drop's id, never the id, because hostnames are visible on the network. The hash is keyed with `VITEHUB_SECRET`, so set it too: `openssl rand -base64 32`, at least 32 characters.

- **Use a domain that serves nothing else**, ideally a separate registrable domain, because a page can set cookies for its parent domain. Drop's sign-in cookies use the `__Host-` prefix, and API writes that carry cookies must come from Drop's own origin.
- **DNS and certificate.** The wildcard needs a wildcard DNS record and a certificate that covers it. Cloudflare's free certificate covers one level under the zone, so `*.drop-usercontent.example.com` needs a paid one. To stay free on your own domain, put the `*` inside the first label: `https://*-drop.example.com` runs each drop at `<hash>-drop.example.com`.
- **No sign-in.** These hostnames serve a blank page that the viewer fills, so private drops never pass through them. Keep them outside oauth2-proxy or any other login wall.
- **A plain hostname** such as `https://drop-usercontent.example.com` also works, but every drop then shares that origin, and its storage.

## Expiry

Drops go to the Trash 30 days after their last visit (14 for temporary ones), stay restorable for 15 days, and are then deleted by the hourly cleanup job. [Review and share](https://drop.vitehub.dev/docs/review.md#expiry) explains what counts as a visit.

| Variable | What it does |
| --- | --- |
| DROP\_EXPIRY\_DAYS | Days a drop lives after its last visit. Defaults to 30. Set 0 to keep every drop. |
| DROP\_CUSTOM\_EXPIRY | Set false so only admins can keep drops. Defaults to true: owners and their agents can too. |

Shortening the window applies to existing drops at once.

## Abuse and moderation

| Setting or page | What it does |
| --- | --- |
| `DROP_SHARE_APPROVAL=true` | A member's public links wait until an admin approves that member on `/admin/review`. On a team Drop, a waiting link still reaches the team. Admins skip the wait, and links shared before you turn it on stay shared. |
| `/report` | Anyone reports a shared link. Admins see reports on `/admin/reports` and dismiss them, quarantine the drop, or ban its owner, which takes down all their drops. Each report logs an audit event; Drop sends no email. |
| `DROP_ABUSE_EMAIL` | Adds a public contact address to the abuse page. |

Before you open your Drop to the public, adapt `app/pages/terms.vue`, `acceptable-use.vue`, and `abuse.vue` to your jurisdiction, with a DMCA contact if you need one. Drops and their files are kept out of search engines.

## Logs

Drop writes one structured evlog event per request: who called, which agent, what it did, and why it failed. On Cloudflare they're in Workers Logs; elsewhere, in the host's log output.

| Field | What it holds |
| --- | --- |
| `version`, `commitHash`, `deployment.host` | The release that answered, and the host it runs on. |
| `user`, `actor` | Who called: a person by id, an agent with its client's name. People's names and emails stay out. |
| `identity.denied`, `identity.session` | Why Drop refused a session (`banned` or `not-member`), or that a session lookup failed. ViteHub Auth refuses sign-ins by `VITEHUB_MEMBERS` itself. |
| `roomAccess.refused` | Which of Drop's access rules refused a realtime connection. |
| `drop` | The drop the request is about, and for a write what it did (`change`) and which fields (`fields`). |
| `mcp.calls` | Each MCP tool call: the tool, its drop, how long it took, and its error. |
| `audit` | Admin and account actions, abuse reports, and billing changes from Stripe. |

**Kept events.** Every event is kept today. Failures, requests slower than a second, and audits are kept even if you lower the sampling rate.

**Left out.** The health check and static files write no event. Upload URLs and password reset links lose their token, and IP addresses are masked.

**The hourly cleanup** writes an `action: "cleanup"` event with its `runId` when ViteHub supplies one, the scheduled time, what each step did, how long it took, and any failures.

**Browser errors.** ViteHub reports uncaught errors on `browserError`. Failures Drop catches go through its own reporter with the response status, request ID, and drop when known. It skips refusals, aborts, offline browsers, pages that are closing, and 5xx responses that carry Drop's own error body.

## Database and migrations

VPS and Docker builds use local SQLite on persistent disk by default. The other hosts each use their own Cloudflare D1 database, over D1's HTTP API outside Cloudflare. All of them apply the migrations in `server/databases/default/migrations`, one folder each.

To create a D1 database for a host outside Cloudflare:

```
npx wrangler login
npx wrangler d1 create my-drop
```

Put its id and name, your Cloudflare account id, and an account API token with Account › D1 › Edit, limited to your account, in the host's settings.

| Host | Applies migrations with |
| --- | --- |
| Cloudflare | `pnpm run deploy`, which the button runs: Wrangler applies them, then deploys the Worker. Workers Builds that run `npx wrangler deploy` need [`DROP_PRODUCTION_BRANCH`](https://drop.vitehub.dev/docs/self-host/cloudflare.md#workers-builds). |
| Vercel, Netlify, Deno Deploy | `pnpm db:migrate` (ViteHub's `vitehub database migrate`) after the build, before publishing. |
| Docker | Drop itself before it listens, after copying the SQLite file to `backups/`; an image built for D1 runs Drop's D1 script before Drop starts. |

`pnpm db:migrate` and the D1 script need `CLOUDFLARE_ACCOUNT_ID`, `CLOUDFLARE_API_TOKEN`, and `CLOUDFLARE_D1_DATABASE_ID`. Every path records migrations in `d1_migrations`, as Wrangler does, and skips those already applied.

`pnpm db:migrate` and Drop's own migration on Docker refuse a migration that would delete existing data. Wrangler on Cloudflare and the D1 script of D1 Docker images have no such check, so read new migrations before you deploy there.

Give previews their own D1 database, or turn preview deployments off: a build with production D1 credentials migrates production.

The first folder creates a new database, and each later one changes it. Never edit a migration a database has already applied: it won't run again there. After you change the schema in `server/databases/default/`, `pnpm db:generate` (ViteHub's `vitehub database generate`) writes the next folder and adds it to `d1-migrations.json`, which gives each folder the file name D1 records it by, such as `0000_init.sql`. Commit both, and never rename one.

## Update

**Each release lists what changed**, and which versions migrate the database, on GitHub Releases. `/api/health` answers with the version and commit a deployment runs.

- **Docker**: pull the new image and restart, as [Updates and backups](https://drop.vitehub.dev/docs/self-host/vps.md#data) shows. Drop backs up its SQLite database before it migrates.
- **Cloudflare, Vercel, Netlify, Deno Deploy**: the button copied Drop into a repository of yours, and the host deploys it on every push. Pull Drop's changes into it, from `main` or a release tag such as `v0.1.0`, and push; the host rebuilds and migrates:

```
git pull https://github.com/vite-hub/drop.git main
git push
```

## Pick a host

Cloudflare has everything Drop uses in one account. A VPS can keep all data on local disk. The serverless hosts use D1 over HTTP, one database per deployment.

| Host | Database | Files | Rate limits | Code images |
| --- | --- | --- | --- | --- |
| [Cloudflare](https://drop.vitehub.dev/docs/self-host/cloudflare.md) | D1 | R2 | Workers rate limiting | PNG and SVG |
| [Vercel](https://drop.vitehub.dev/docs/self-host/vercel.md) | D1 over HTTP | Vercel Blob | Per instance | SVG |
| [Netlify](https://drop.vitehub.dev/docs/self-host/netlify.md) | D1 over HTTP | Netlify Blobs | Per instance | SVG |
| [Deno Deploy](https://drop.vitehub.dev/docs/self-host/deno.md) | D1 over HTTP | R2 S3 API | Per instance | SVG |
| [VPS](https://drop.vitehub.dev/docs/self-host/vps.md) | Local SQLite or D1 | Local disk | In memory | SVG |

## Choose the host at build time

Drop builds for the host that ViteHub detects. ViteHub reads `VITEHUB_HOST`, then `NITRO_PRESET` or `SERVER_PRESET`, then the Cloudflare Workers Builds, Netlify, Vercel, or Deno markers. With none of them, a local `DROP_DATABASE_URL` selects VPS, and no signal builds for Cloudflare. Docker always builds for VPS.

```
VITEHUB_HOST=vercel pnpm build   # explicit override: cloudflare, vercel, netlify, deno, or node for VPS
```

When upgrading, replace `DROP_HOST` with `VITEHUB_HOST` in your build environment. Use `VITEHUB_HOST=node` in place of `DROP_HOST=vps`; other host names stay the same. Existing `DROP_HOST` settings still work during migration, but `VITEHUB_HOST` takes precedence when both are set.

`DROP_DATABASE=sqlite` or `DROP_DATABASE=d1` picks the database at build time. SQLite needs the VPS preset and persistent disk, and an existing D1 database id keeps a VPS build on D1. To change drivers, rebuild and migrate the data yourself.

`nuxt.config.ts` maps each host to its ViteHub preset and drivers, so the app's code stays the same on every host.

## What changes between hosts

|  | Cloudflare | Other hosts |
| --- | --- | --- |
| Code images | PNG (a Browser Run screenshot of the SVG) and SVG. | SVG only. Asking `create_code_image` for PNG fails with a clear error. |
| Rate limits | Cloudflare's rate limiting binding. | Counted in memory per server instance, so looser on serverless hosts. |
| Cleanup | Hourly. | Hourly on a VPS and Netlify, daily on Vercel so it works on Hobby. Deno Deploy has none: trashed drops and expired images stop being served but stay in the bucket. |
| Caching | Rendered Markdown and the file count in Workers KV. | In memory. |

The cleanup job moves expired drops to the Trash, deletes what has been there 15 days, and removes expired code images and OAuth clients unused for a day.

## Check a deployment

The smoke test checks the public pages, the OAuth discovery documents, that `/mcp` asks agents to sign in, and the skills index. Add `DROP_TOKEN=<an MCP access token>` to also run uploads, sharing, and the MCP tools.

```
DROP_URL=https://<your-domain> pnpm test:e2e:deployed
```

## Develop locally

```
pnpm install
pnpm db:migrate   # once, and after schema changes
pnpm dev          # http://localhost:3000
```

Local dev runs against a local D1 and keeps files in `.vitehub/data/blob`. It has no GitHub app, so it also allows email and password sign-in: open `/?signin=1`.

### Adopt an older SQLite migration ledger

Before upgrading a SQLite deployment that ran the original comment-suggestions migration, stop Drop and back up its database. Run `node scripts/adopt-sqlite-ledger.mjs /path/to/drop.db` from this checkout before running Drizzle or starting the new server. This adopts only the known shipped hash at its original journal timestamp; it never replays SQL or rewrites migration files. Other unknown hashes still fail closed. The Docker entry point performs this adoption after its backup.
