Overview
As an operator, you host the bassh infrastructure on your Cloudflare account. Your users can deploy static sites without needing their own Cloudflare accounts—they just need an invite code from you.
What you'll set up:
- Cloudflare Worker — Handles API requests, user registration, and deployments
- KV Namespaces — Store user data and form submissions
- API Token — Grants the Worker permission to create Pages projects
What your users get:
- Deploy static sites with a single command
- Password protection, email access controls, magic links
- Form submissions without a backend
- Custom domains with automatic SSL
Requirements
- Cloudflare account (free tier works)
- Node.js 18+ installed
- 10 minutes
- Optional: Resend account for magic link emails
Quick Setup
The fastest way to get started. Clone the repo and run the setup script.
One-command setup
The setup script handles authentication, KV creation, configuration, and deployment automatically.
# Clone to home directory (required for deploy alias) git clone https://github.com/get-bassh/bassh.git ~/bassh cd ~/bassh # Run the setup script ./setup.sh
The script will:
- Authenticate with Cloudflare (opens browser if needed)
- Create KV namespaces for users and forms
- Generate
wrangler.tomlconfiguration - Prompt for your API token
- Configure registration mode (invite-only or open)
- Deploy the Worker
- Display your invite code to share with users
The setup script works on both macOS and Linux.
Manual Setup
If you prefer to understand each step or need custom configuration, follow these steps.
1Install Wrangler
Wrangler is Cloudflare's CLI for managing Workers.
npm install -g wrangler wrangler login
This opens your browser to authenticate with Cloudflare.
2Clone the Repository
git clone https://github.com/get-bassh/bassh.git ~/bassh cd ~/bassh
Clone to ~/bassh so the deploy alias works correctly.
3Create KV Namespaces
bassh uses two KV namespaces to store user data and form submissions.
npx wrangler kv namespace create USERS Created namespace "bassh-api-USERS" with id "abc123..." npx wrangler kv namespace create FORMS Created namespace "bassh-api-FORMS" with id "def456..."
Save these IDs—you'll need them for the configuration file.
4Create API Token
The Worker needs an API token to create Pages projects and Access policies.
- Go to Cloudflare API Tokens
- Click Create Token
- Select Create Custom Token
- Add these permissions:
| Scope | Permission | Access |
|---|---|---|
| Account | Workers KV Storage | Edit |
| Account | Cloudflare Pages | Edit |
| Account | Access: Apps and Policies | Edit |
| Account | Account Settings | Read |
| Zone | Email Routing Rules | Edit (optional) |
- Set Account Resources to include your account
- Set Zone Resources to include all zones
- Click Continue to summary → Create Token
- Copy the token immediately (you won't see it again)
Create a dedicated token for bassh. Never reuse your global API key.
5Configure wrangler.toml
Update wrangler.toml with your KV namespace IDs:
name = "bassh-api" main = "src/index.ts" compatibility_date = "2024-01-01" [[kv_namespaces]] binding = "USERS" id = "your-users-namespace-id" [[kv_namespaces]] binding = "FORMS" id = "your-forms-namespace-id"
6Set Secrets
Configure the required secrets for your Worker:
# Required: Your Cloudflare Account ID npx wrangler secret put CF_ACCOUNT_ID > Enter value: your-32-char-account-id # Required: API Token from Step 4 npx wrangler secret put CF_API_TOKEN > Enter value: your-api-token # Optional: Enable invite-only registration npx wrangler secret put REGISTRATION_CODE > Enter value: your-secret-invite-code
Find your Account ID with:
npx wrangler whoami
7Deploy
npx wrangler deploy Deployed bassh-api to https://bassh-api.your-subdomain.workers.dev
Add a convenience alias to your shell config (~/.zshrc or ~/.bashrc):
alias bassh-deploy="npx wrangler deploy --config ~/bassh/wrangler.toml"
Managing Invite Codes
Control who can register on your bassh instance.
Invite-only mode (recommended)
When you set REGISTRATION_CODE, users need an invite to register:
# Your invite code format: subdomain:secret your-subdomain:your-secret-code # Users register with bassh register alice --invite your-subdomain:your-secret-code
Open registration
Without REGISTRATION_CODE, anyone with your Worker URL can register:
# Users set the API endpoint export BASSH_API=https://bassh-api.your-subdomain.workers.dev # Then register without invite bassh register alice
Rotating invite codes
To change the invite code, update the secret:
npx wrangler secret put REGISTRATION_CODE > Enter value: new-secret-code
Existing users are unaffected—only new registrations need the new code.
Email Magic Links
Enable the -o flag for email-based site protection with magic links.
Setup with Resend
- Create a Resend account
- Add and verify your domain
- Add the required DNS records (SPF, DKIM)
- Generate an API key
- Set the secrets:
npx wrangler secret put RESEND_API_KEY > Enter value: re_abc123... npx wrangler secret put EMAIL_FROM > Enter value: access@yourdomain.com
The EMAIL_FROM address must use the domain you verified in Resend.
Your users can now protect sites with magic links:
bassh ./dist -o "alice@company.com,@trusted.com"
Custom Workers Subdomain
Choose a memorable subdomain for your Worker URL.
- Go to Cloudflare Dashboard → Workers & Pages
- Click on your account subdomain settings
- Change to something memorable (e.g.,
myteam) - Redeploy your Worker
Your Worker URL will be: https://bassh-api.myteam.workers.dev
Secrets Reference
| Secret | Required | Description |
|---|---|---|
CF_ACCOUNT_ID |
Yes | Your Cloudflare account ID |
CF_API_TOKEN |
Yes | API token with Pages and Access permissions |
REGISTRATION_CODE |
No | Secret code for invite-only registration |
RESEND_API_KEY |
No | Resend API key for magic link emails |
EMAIL_FROM |
No | Sender email for magic links |
Troubleshooting
Deployment fails
Check that your API token has all required permissions. Re-create the token if needed.
Users can't register
- Verify
REGISTRATION_CODEis set correctly - Check the invite code format:
subdomain:secret - Ensure the subdomain matches your workers.dev subdomain
Magic links not sending
- Verify Resend domain is fully verified (check DNS records)
- Ensure
EMAIL_FROMuses the verified domain - Check Resend dashboard for sending errors
KV errors
- Verify namespace IDs in
wrangler.tomlmatch what you created - Ensure API token has Workers KV Storage Edit permission