Add e-signatures and clickwrap to an app on Vercel
To add e-signatures and clickwrap to an app on Vercel, store the secret key as an Environment Variable: the test key for Preview and Development, the live key for Production. A Route Handler on Vercel Functions creates the session, and a second one confirms the record against VERCEL_ENV. Esign Comply seals the record, and your database keeps the receipt.
Follow the quickstart and each signature is a valid electronic signature under the U.S. ESIGN Act, state UETA laws and New York's ESRA, and each clickwrap is built the way courts require: clear notice of the terms, an unmistakable act of assent, and a sealed record of both.
$npm install esigncomply @esigncomply/react @esigncomply/browser server-onlyFree plan: 10 live signatures a month and a full test mode. No card required.
Last updated
export const esc = new EsignComply(process.env.ESIGNCOMPLY_API_KEY!); // Vercel sets VERCEL_ENV on every deployment: "production", "preview" or "development". // Production holds the live key and accepts live records only. export const LIVE = process.env.VERCEL_ENV === "production";
// app/api/ceremony/route.ts import { randomUUID } from "node:crypto"; import { savePinned } from "@/lib/ceremony-state"; import { DOCUMENTS, esc, signer } from "@/lib/esigncomply"; // A Route Handler runs as a Vercel Function. The secret key never leaves it. export async function POST(request: Request) { const { data: session, error } = await esc.sessions.create( { profile: process.env.ESIGNCOMPLY_PROFILE_ID!, signer, documents: [ { document: DOCUMENTS.terms!, version: "current" }, { document: DOCUMENTS.privacy!, version: "current" }, ], // The origin the browser reports: localhost, a preview URL or your production domain. context: { url: `${request.headers.get("origin") ?? new URL(request.url).origin}/signup`, locale: "en-US", purpose: "account_signup" }, }, { idempotencyKey: `signup-${signer.external_id}-${randomUUID()}` }, ); if (error) return Response.json({ error: error.code, message: error.message }, { status: 502 }); await savePinned({ signerId: signer.external_id, versionIds: session.documents.map((d) => d.version_id) }); return Response.json({ clientToken: session.client_token, apiUrl: session.api_url, documents: session.documents }); }
const COOKIE = "esc_ceremony"; const MAX_AGE = 30 * 60; // seconds: the lifetime of a session function sign(value: string): string { const secret = process.env.CEREMONY_STATE_SECRET; if (!secret) throw new Error("CEREMONY_STATE_SECRET is not set"); return createHmac("sha256", secret).update(value).digest("base64url"); } export async function savePinned(pinned: Pinned): Promise<void> { const value = Buffer.from(JSON.stringify({ ...pinned, exp: Date.now() + MAX_AGE * 1000 })).toString("base64url"); (await cookies()).set(COOKIE, `${value}.${sign(value)}`, { httpOnly: true, secure: process.env.NODE_ENV === "production", sameSite: "lax", path: "/", maxAge: MAX_AGE, }); } export async function loadPinned(): Promise<Pinned | null> { const [value, mac] = ((await cookies()).get(COOKIE)?.value ?? "").split("."); if (!value || !mac) return null; const expected = Buffer.from(sign(value)); const given = Buffer.from(mac); if (given.length !== expected.length || !timingSafeEqual(given, expected)) return null; const state = JSON.parse(Buffer.from(value, "base64url").toString()) as Pinned & { exp: number }; return state.exp > Date.now() ? { signerId: state.signerId, versionIds: state.versionIds } : null; }
// app/api/signup/confirm/route.ts import { loadPinned } from "@/lib/ceremony-state"; import { esc, LIVE } from "@/lib/esigncomply"; const SEALED = ["recorded", "timestamped", "anchored"]; export async function POST(request: Request) { const { recordId } = await request.json(); const pinned = await loadPinned(); const { data: record, error } = await esc.records.get(String(recordId)); if (error || !pinned) return Response.json({ confirmed: false }, { status: 409 }); const confirmed = SEALED.includes(record.status) && record.livemode === LIVE && record.signer.external_id === pinned.signerId && JSON.stringify(record.documents.map((d) => d.version_id).sort()) === JSON.stringify([...pinned.versionIds].sort()); console.log(confirmed ? `confirmed ${record.id} (${record.status})` : "refused"); if (!confirmed) return Response.json({ confirmed: false }, { status: 409 }); // Only now create the account, and store record.id and record.receipt with it. return Response.json({ confirmed: true, recordId: record.id }); }
How do you integrate Esign Comply with Vercel?
The integration path on Vercel is Next.js Route Handlers, which run as Vercel Functions. Three things are specific to the platform: the key each environment holds, VERCEL_ENV as the test that a deployment is production, and state that does not sit in memory, because two requests can run in two function instances.
Vercel creates a new function invocation for each incoming request, and reuses a function instance when another request arrives soon after the previous one.
Source: Vercel documentation, Vercel Functions, read on .- VERCEL_ENVlib/esigncomply.ts
- Session functionapp/api/ceremony/route.ts
- Signed statelib/ceremony-state.ts
- Confirm functionapp/api/signup/confirm/route.ts
Run on 2026-11-26 with Next.js 16.4.6 under next dev, with VERCEL_ENV set by hand to preview and to production, esigncomply 1.0.4, @esigncomply/react 1.0.1, @esigncomply/browser 1.0.4 and the conformance check from esigncomply 1.0.4, against the API in test mode. The Vercel settings are from Vercel's documentation as of 2026-11-23. The code has not yet been run on a Vercel deployment.
How does Esign Comply fit with Vercel?
Each step uses a feature Vercel already has. The secret key stays on the server side of Vercel in all three.
- 01Environment Variables hold the key, one per environmentAdd
ESIGNCOMPLY_API_KEYin the project's Environment Variables: the test key applied to Preview and Development, the live key applied to Production only. A preview deployment can then never write a live record. Source: Vercel documentation, Environment variables, read on . - 02A Vercel Function creates the sessionA Next.js Route Handler,
app/api, calls/ceremony /route.ts esc.sessions.createwith the secret key and returns the client token. The React hooks run the ceremony in the browser, straight from the signer's device to the API. - 03A second function confirms against VERCEL_ENV
app/apireads the record and expects a live one only when/signup /confirm /route.ts VERCEL_ENVisproduction. Your database keeps the record ID and the receipt beside the user. Source: Vercel documentation, System environment variables, read on .
Where do the key, the preview hosts and the webhook go on Vercel?
Four settings carry an Esign Comply integration on Vercel. What is said here about Vercel was read from its own documentation, and the quickstart has each command.
Environment variables
Set them in the project's settings under Environment Variables, or with vercel env add ESIGNCOMPLY_API_KEY --environment production --sensitive. Changes apply to new deployments only, so redeploy after you add one. vercel env pull writes the Development values to .env.local.
Source: Vercel documentation, Environment variables, read on .
Preview deployments and test mode
A test key refuses a host it does not know. Each Git branch has a stable address, <project-name>-git-<branch-name>-<scope-slug>.vercel.app: list that host under Domains in the Esign Comply dashboard as a test origin and open previews through it. List exact hosts, never the shared suffix vercel.app.
Source: Vercel documentation, Generated URLs, read on .
The registered domain
Register your custom domain and verify it with one DNS record. A production app on a vercel.app host verifies with a file instead: a Route Handler at app/.well-known serves the token from an Environment Variable.
The webhook endpoint
Add a Route Handler for the record.completed webhook and register its production URL under Webhooks in the Esign Comply dashboard. It backs the confirmation up when the browser closes before your function hears about the record.
Read on : Vercel documentation, Environment variables, Vercel documentation, System environment variables, Vercel documentation, Generated URLs, Vercel documentation, Vercel Functions, Vercel documentation, vercel env.
What prompt adds Esign Comply clickwrap to a Vercel app?
Paste this into Cursor, Claude Code or the AI coding tool that is open on your project. It names the packages that exist, where the secret key goes on Vercel, what to build and what never to do, and it ends with the rules block for your project.
The rules block lives at /rules.md. Added to your project's instruction file, it makes every later session build signing and acceptance flows the same way. The prompt generator writes the long version, with your own document and profile IDs.
Pages for each AI toolAdd Esign Comply clickwrap to my Next.js app on Vercel: a signup form where the user accepts the Terms of Service and the Privacy Notice with a checkbox and a button.
Read these first and follow them exactly. If something conflicts with existing code, or you are unsure how to implement a step, stop and ask. Do not invent API methods, packages or legal wording.
- https://esigncomply.com/docs/quickstart/vercel.md (the steps and the tested code for Vercel)
- https://esigncomply.com/setup.md (the order of API calls)
- https://esigncomply.com/auth.md (how to handle the keys)
Vercel facts
- Packages (the only ones that exist): esigncomply (server), @esigncomply/react (hooks) and @esigncomply/browser.
- The secret key is the Environment Variable ESIGNCOMPLY_API_KEY: the test key for Preview and Development, the live key for Production only. Never give it a NEXT_PUBLIC_ name. Never print it.
- Expect live records only when process.env.VERCEL_ENV is "production". A preview deployment also has NODE_ENV "production", so NODE_ENV cannot tell them apart.
- Two requests can run in two function instances. Keep the pinned version IDs in the database, or in an httpOnly cookie signed with a secret. Never in memory.
- A preview deployment runs on its own vercel.app host. Test keys refuse that host until it is listed under Domains as a test origin. List the branch URL, never the shared suffix vercel.app.
- The form is in the server HTML before the page hydrates: render the checkbox disabled and enable it when observeAssent has resolved.
Build
1. Verify the key: GET /v1/usage with ESIGNCOMPLY_API_KEY. Stop if it fails.
2. Register the Terms of Service and the Privacy Notice as documents and publish one version of each from the documents in this project. If the project has none, register short sample documents and say so in your report. Never write or change the wording of the real documents. Create a profile: jurisdictions ["US-FED"], method "checkbox", assurance_level "L1".
3. Route Handler app/api/ceremony/route.ts: create the session with esc.sessions.create and an Idempotency-Key, save the signer ID and the pinned version IDs in server-owned state, and return only clientToken, apiUrl and documents.
4. Server Component app/legal/[slug]/page.tsx: render the registered version from esc.documents.versions.getContent inside <article data-esc-document>, unmodified.
5. Client component: useCeremony({ clientToken, apiUrl }), useDocument for each link, ceremony.observeAssent({ region, checkbox, submit }) from an effect, then ceremony.complete() in the submit handler. Request the session once per page load, from a promise kept outside the component.
6. Route Handler app/api/signup/confirm/route.ts: read the record with esc.records.get and require: status is "recorded", "timestamped" or "anchored"; livemode equals (VERCEL_ENV === "production"); the signer ID and version IDs equal the server-owned state. Only then create the account.
Never
- Never pre-check the box, auto-submit, or call .click() on the user's behalf.
- Never use "By continuing" or "By clicking below" wording. The notice names the button by its label and each document by its registered name.
- Never put the secret key, or any call that uses it, in code that reaches the browser.
- Never show "signed" or "accepted" before the server has confirmed the record.
- Never fall back to an acceptance with no record when a session is refused.
Check before you report success
- Run: npx esigncomply check --url http://localhost:3000/signup --callback http://localhost:3000/api/signup/confirm
Fix every finding marked "block". List every finding marked "warn".
- Report the files you created or changed, anything you did not implement and why, and the conformance summary.
Then add the rules block to this project's instruction file: https://esigncomply.com/rules.mdWhat goes wrong when you add e-signatures on Vercel?
These are specific to Vercel. Each one was seen while the quickstart's code was run, or is in Vercel's own documentation.
- 01
A preview deployment is a production build
NODE_ENVisproductionon a preview, while its key is a test key. ComparelivemodewithVERCEL_ENV === "production". In a local test withVERCEL_ENVset toproductionand a test key, the confirm route refused the test record with409. - 02
Two requests can run in two function instances
What your server pinned when it created the session cannot sit in a variable. The quickstart carries it in an httpOnly cookie signed with a secret: in the test, a cookie whose payload had been changed was refused. A table in your database does the same job.
- 03
A preview host is refused until you list it
In a local test, a session requested from
https:/was refused with/myapp-git-main-acme.vercel.app domain_mismatch, and accepted once that host was a test origin of the domain. Use the branch URL, which stays the same across commits.
Where are the Vercel quickstart and the API reference?
Start with the quickstart: it carries every file this page excerpts, in the order you write them.
- QuickstartVercel quickstartStep by step, from install to your first sealed test record, with every file and the output of each step.Open
- ReferenceAPI referenceEvery endpoint, field and error code. Sessions, records and documents are the three this page uses.Open
- Long guideClickwrap in Next.js and SupabaseThe full Next.js build with a database table for the receipt, which is what a Vercel deployment needs.Open
- GuideServer confirmationThe one place access is granted: what to compare, and the webhook that backs the check up.Open
What does Esign Comply record for a signature on Vercel?
The same record on every stack and platform. Your Vercel code creates the session and confirms the record, and the browser SDK reports what happened on the page. Esign Comply seals the result where your code cannot change it. The record itself is described on Evidence and verification.
Observed and asserted fields
Every field is tagged. Observed is what the browser SDK and the API saw: the box unchecked at load, the tick from a trusted user event, the notice text, the terms version by hash, the server time. Asserted is what your app said, such as the user's email.
A signed receipt
complete()returns a receipt signed with ES256, using keys you do not hold. Your server stores it next to the user, andGET /v1returns it again./records /{id} /receipt An external timestamp
An outside authority timestamps the hash of every live record (RFC 3161), so the time on the record does not rest on your clock or on ours.
An offline verifier
Each record has an evidence report (PDF) and an evidence package (ZIP). Anyone you send the package to checks the acceptance with the open-source
esigncomply-verify, without an account.
Questions about e-signatures on Vercel
How does test mode work on Vercel preview URLs?
A test key works on a preview once the preview's host is listed as a test origin of your domain. Vercel gives each Git branch a stable address that ends in vercel.app: list that host and open previews through it. Without the entry the session is refused with domain_mismatch.
Where should the receipt be stored on Vercel?
In your own database, beside the user, with the record ID. Vercel Functions keep nothing between requests, so the confirm function writes both values to your table once the record is confirmed. Esign Comply keeps the sealed record itself.
Which key goes in which Vercel environment?
The test key in Preview and Development, the live key in Production only. Vercel applies each Environment Variable to the environments you select, so one name, ESIGNCOMPLY_API_KEY, holds a different key in each.
Do I need a custom domain to go live on Vercel?
No. A production app on a vercel.app host registers that host as its domain and verifies it with a file at /.well-known, because you cannot add DNS records there. With a custom domain you verify by DNS instead.
Was this code run on Vercel?
Not yet. It was run on localhost with Next.js 16.4.6 and VERCEL_ENV set by hand, and the Vercel settings come from Vercel's documentation as of November 23, 2026. Environment scoping, the function runtime and file verification on a vercel.app host are proven only by a deployment.
Ship the signup on Vercel. Leave the record to us.
Free plan: 10 live signatures a month and a full test mode. No card required.
Vercel is a trademark of its owner. Esign Comply is not affiliated with it. What this page says about Vercel is from Vercel's documentation or from a test run, as marked, on . /vercel.md is this page as Markdown.