Deploy on Cloudflare
Everything fits in the Workers free/paid plans: one Worker, one D1 database, one R2 bucket.
1. Create the resources
Section titled “1. Create the resources”cd apps/servernpx wrangler loginnpx wrangler d1 create airdrop # copy the database_id into wrangler.jsoncnpx wrangler r2 bucket create airdrop-assets2. Configure and deploy
Section titled “2. Configure and deploy”openssl rand -base64 32 | npx wrangler secret put ADMIN_TOKENpnpm run deploy # applies D1 migrations, then deploys the WorkerThe 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.
3. Use it
Section titled “3. Use it”airdrop login --server https://ota.example.com --token <ADMIN_TOKEN>airdrop tokens create ci # for pipelines, instead of the admin tokenDeploy from GitHub Actions
Section titled “Deploy from GitHub Actions”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.
Configuration
Section titled “Configuration”| 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.