1
Fork and clone
You can also import the repo directly into Vercel and skip local cloning.
2
Create Redis (Upstash recommended)
- Visit https://console.upstash.com/redis
- Create a database and copy both:
- the connection host (host:port or rediss://…)
- the password
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
You should see a JSON response like
{“id”:“home”,“hits”:1} from /hit and a number from /count.txt.5
Deploy to Vercel
- Push your fork to GitHub.
- Import the repo in Vercel: https://vercel.com/new
- Add the same env vars in Project → Settings → Environment Variables.
- 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.Troubleshooting
Troubleshooting
- 401 on /hit: check
SECRET_TOKENin 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).