Skip to main content
This guide helps you set up nums with Upstash Redis, run it locally, deploy to Vercel, and verify everything works end‑to‑end.
1

Fork and clone

You can also import the repo directly into Vercel and skip local cloning.
2

Create Redis (Upstash recommended)

If you provide both UPSTASH_REDIS_URL and UPSTASH_REDIS_PASSWORD, nums will build a proper REDIS_URL automatically.
3

Configure environment variables

Create a .env file in the repo root:
Only /hit requires a secret. Read endpoints (/count, /count.txt, /badge, /badge.json) are public.
4

Run locally

Verify endpoints:
You should see a JSON response like {“id”:“home”,“hits”:1} from /hit and a number from /count.txt.
5

Deploy to Vercel

  1. Push your fork to GitHub.
  2. Import the repo in Vercel: https://vercel.com/new
  3. Add the same env vars in Project → Settings → Environment Variables.
  4. Deploy. Your URL will look like https://<project>.vercel.app (or your custom domain).
Never expose your secret token in client-side code. For client websites, route increment requests through a server function.
6

Add a badge to your README

  • Shields (recommended):
  • Direct SVG (terminal style):
cacheSeconds in /badge.json is clamped to 30–3600 seconds.
  • 401 on /hit: check SECRET_TOKEN in the header or ?token=.
  • Count stuck at 0: call /hit?id=… at least once; verify Redis env vars.
  • Vercel envs: ensure variables are set for the right environment (Preview/Production).