Skip to content

Deploy on Cloudflare

Everything fits in the Workers free/paid plans: one Worker, one D1 database, one R2 bucket.

Terminal window
cd apps/server
npx wrangler login
npx wrangler d1 create airdrop # copy the database_id into wrangler.jsonc
npx wrangler r2 bucket create airdrop-assets
Terminal window
openssl rand -base64 32 | npx wrangler secret put ADMIN_TOKEN
pnpm run deploy # applies D1 migrations, then deploys the Worker

The Worker is now at https://airdrop-server.<your-subdomain>.workers.dev. Optionally add a custom domain (Workers → Settings → Domains & Routes), e.g. ota.example.com, and set PUBLIC_URL if assets should be served from a different hostname.

Terminal window
airdrop login --server https://ota.example.com --token <ADMIN_TOKEN>
airdrop tokens create ci # for pipelines, instead of the admin token

Three workflows ship with the repo (all can be run manually from the Actions tab):

workflow what it does secrets
deploy-server.yml D1 migrations, worker deploy, sets ADMIN_TOKEN, smoke test CLOUDFLARE_API_TOKEN, AIRDROP_ADMIN_TOKEN
deploy-web.yml builds and deploys the landing page + docs CLOUDFLARE_API_TOKEN
release.yml publishes react-native-airdrop and react-native-airdrop-cli to npm NPM_TOKEN

Set account_id in apps/server/wrangler.jsonc and apps/web/wrangler.jsonc to your account. The Cloudflare token needs Workers Scripts: Edit, D1: Edit and Workers R2 Storage: Edit on that account. The npm token must be a granular token with Bypass two-factor authentication.

name kind
ADMIN_TOKEN secret bootstrap admin token
CHECK_CACHE_TTL var seconds the candidate list is cached per colo (default 10, 0 disables)
PUBLIC_URL var base URL used in asset links (default: request origin)

Per device launch: one Worker request for /v1/check (D1 reads amortized by the per-colo cache) and, only when there is an update, one request per changed file, mostly served from the edge cache. R2 has no egress fees.