What is Altcha?
Altcha is an open-source, self-hostable CAPTCHA alternative based on proof-of-work rather than tracking or image puzzles. The server issues a signed challenge; the client's browser solves it with a small amount of computation, then submits the solution back for verification.
The signature on each challenge is an HMAC-SHA256 computed with a secret key — ALTCHA_HMAC_KEY. Anyone who knows this key can forge valid-looking solutions, so it must stay server-side only and never ship to the client bundle.
How to add it to your project
- Copy the generated key into your server-side
.env:ALTCHA_HMAC_KEY=<paste here> - Pass it to
altcha-libwhen creating and verifying challenges:import { createChallenge, verifySolution } from 'altcha-lib'; const challenge = await createChallenge({ hmacKey: process.env.ALTCHA_HMAC_KEY!, }); const ok = await verifySolution(payload, process.env.ALTCHA_HMAC_KEY!); - Never expose
ALTCHA_HMAC_KEYto the client — it belongs only in server-side environment variables (API routes, Edge Functions), not inNEXT_PUBLIC_*or client bundles.