Minimal Next.js app showcasing a tasks list with a serverless API (CRUD) for practicing serverless functions and simple state management.
What’s included
pages/tasks.js— UI for listing, creating, toggling, and deleting taskspages/api/tasks.js— API route supporting GET/POST/PUT/DELETEdata/tasks.json— demo file-backed store (ephemeral on serverless platforms)pages/index.js,pages/_app.js,styles/global.css— entry and global styles
Run locally
npm install
npm run dev
# then open the URL shown in the terminal (e.g. http://localhost:3000/)Deploying to Vercel
- This repository is ready for Vercel. Use the web UI to import the repo or the CLI:
npm install -g vercel
vercel login
vercelImportant: data persistence
- The current API writes to
data/tasks.jsonon disk. Vercel serverless functions run in ephemeral environments — disk writes are not persistent across invocations or deployments. For a production-ready app, switch to a persistent data store (recommended options below).
Persistent storage options
- Vercel KV — fast, simple key/value store (recommended for small demo apps)
- Vercel Postgres — relational database on Vercel
- Supabase / Firebase — hosted DB + realtime and auth
Quick notes to switch to Vercel KV
- Provision Vercel KV in your Vercel dashboard.
- Add the KV connection string as an environment variable (e.g.
VERCEL_KV_URL) in your Vercel project settings. - Update
pages/api/tasks.jsto use@vercel/kv(or direct fetch) instead of the file-based store.
Branches
main— defaultstaging— created for deployment/testingfeature— current feature branch (Clear completed)
Git / PRs
- Push branches and create PRs from GitHub (example):
git push -u origin staging
git push -u origin feature
# then open the PR URLs suggested by `git push` or visit your repo on GitHubIf you want, I can update the API to use Vercel KV or Supabase and add environment variable instructions and sample code.