Skip to content

Quick start

This guide adds HumanPass to an HTML form and verifies the response with the official server SDK.

In the Valgix dashboard:

  1. Select Create site.
  2. Enter a name and choose Test while developing locally.
  3. Add your exact domain. Use localhost only with a test site.
  4. Copy the secret key immediately. It is shown only once.

You will receive:

  • a public sitekey for browser code;
  • a private secret key for your backend.

Load an immutable widget version and place the component inside your form:

<script
src="https://humanpass.valgix.com/widget/0.1.0/humanpass.min.js"
defer
></script>
<form method="post" action="/signup">
<input name="email" type="email" required />
<humanpass-widget
data-humanpass-sitekey="hp_site_test_REPLACE_ME"
data-humanpass-action="signup"
required
></humanpass-widget>
<button type="submit">Create account</button>
</form>

The widget adds a hidden humanpass-token field to the form. The configured mode comes from the Valgix dashboard; browser markup cannot override it.

Terminal window
npm install @valgix/humanpass

The package supports Node.js 20 or later and Bun.

Store the secret in a server-only environment variable:

HUMANPASS_SECRET_KEY=hp_secret_test_REPLACE_ME

Never prefix this variable with NEXT_PUBLIC_, PUBLIC_, or another framework convention that exposes it to browsers.

import { HumanPass } from "@valgix/humanpass";
const humanpass = new HumanPass({
baseUrl: "https://humanpass.valgix.com",
secret: process.env.HUMANPASS_SECRET_KEY!,
});
const result = await humanpass.verify({
response: formData.get("humanpass-token")?.toString() ?? "",
expectedAction: "signup",
expectedHostname: "app.example.com",
});
if (!result.success) {
return new Response("Human verification failed", { status: 400 });
}
// Continue the protected signup only after successful verification.

Response tokens are short-lived and single-use. Verify immediately before the operation you want to protect.

Before production:

  1. Create a live site or live credentials.
  2. Add every production hostname you use.
  3. Replace the test sitekey and secret with their live equivalents.
  4. Confirm your backend expects the production hostname and action.
  5. Exercise both successful and rejected requests.

Test and live credentials cannot be mixed.