TinyWebDB deployment for Vercel Edge Functions with KV storage.
- Global edge deployment: Runs on Vercel's Edge Network
- Low latency: Redis-based KV storage with sub-millisecond reads
- Free tier: Generous limits on Vercel's Hobby plan
- Serverless: Automatic scaling with zero configuration
- A Vercel account (sign up for free)
- Vercel CLI installed (optional for manual deployment):
npm install -g vercel
The easiest way to deploy is using the one-click button:
This will:
- Clone the repository to your GitHub account
- Create a new Vercel project
- Automatically create a Vercel KV database
- Deploy your TinyWebDB service
cd packages/vercel-kv
npm installUsing Vercel CLI:
vercel link # Link to your Vercel project
vercel kv create tinywebdb-kv # Create KV databaseOr via Vercel Dashboard:
- Go to your project
- Navigate to "Storage" tab
- Create a new KV database
- Name it
tinywebdb-kv
The KV database credentials will be automatically linked to your project. Verify by checking:
vercel env lsYou should see:
KV_REST_API_URLKV_REST_API_TOKEN
npm run deployOr using Vercel CLI:
vercel --prodYour TinyWebDB service will be deployed to:
https://your-project-name.vercel.app
# Pull environment variables from Vercel
vercel env pull .env.local
# Start development server
npm run devThis starts a local development server at http://localhost:3000.
npm run buildOnce deployed, your service will have these endpoints:
curl -X POST https://your-project.vercel.app/storeavalue \
-H "Content-Type: application/json" \
-d '{"tag":"mykey","value":"myvalue"}'curl -X POST https://your-project.vercel.app/getvalue \
-H "Content-Type: application/json" \
-d '{"tag":"mykey"}'curl -X POST https://your-project.vercel.app/deleteentry \
-H "Content-Type: application/json" \
-d '{"tag":"mykey"}'To use a custom domain:
- Go to your project settings in Vercel Dashboard
- Navigate to "Domains"
- Add your custom domain
- Follow the DNS configuration instructions
Vercel automatically creates preview deployments for each branch:
- Production:
mainbranch →your-project.vercel.app - Preview: Other branches →
your-project-git-branch.vercel.app
To use different KV databases per environment:
- Create separate KV databases (e.g.,
tinywebdb-kv-prod,tinywebdb-kv-dev) - Link them to specific branches in Vercel Dashboard
- Configure environment variables per environment
Vercel KV pricing (as of 2024):
Hobby (Free) plan:
- 256 MB storage
- 3,000 commands/day
- Global replication
Pro plan ($20/month):
- 1 GB storage included
- 100,000 commands/day included
- Additional: $1/GB storage, $0.25 per 100K commands
See Vercel KV pricing for details.
- Eventually consistent: KV replication is eventually consistent across regions
- Key size limit: 1 KB
- Value size limit: 100 MB (JSON payload limits apply)
- Command limit: Free tier limited to 3,000 commands/day
Make sure you've:
- Created a Vercel KV database
- Linked it to your project
- Pulled environment variables locally:
vercel env pull .env.local
You've hit the daily command limit. Either:
- Wait for the daily reset
- Upgrade to a paid plan
- Optimize your application to reduce KV operations
- Ensure you're logged in:
vercel login - Check that dependencies are installed:
npm install - Verify your project is linked:
vercel link
If you need to enable CORS for browser requests, modify the response headers in api/index.ts:
return new Response(httpResponse.body, {
status: httpResponse.status,
headers: {
...httpResponse.headers,
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type',
},
});MIT