Skip to content
Platform · Vercel

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-only
Vercel quickstart

Free plan: 10 live signatures a month and a full test mode. No card required.

Last updated

Run locally for Vercel before publishing
lib/esigncomply.ts (excerpt)
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";
Integrate with Vercel

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 .
Where each part lives on Vercel
  • 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.

Three steps

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.

  1. 01
    Environment Variables hold the key, one per environmentAdd ESIGNCOMPLY_API_KEY in 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 .
  2. 02
    A Vercel Function creates the sessionA Next.js Route Handler, app/api/ceremony/route.ts, calls esc.sessions.create with 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.
  3. 03
    A second function confirms against VERCEL_ENVapp/api/signup/confirm/route.ts reads the record and expects a live one only when VERCEL_ENV is production. Your database keeps the record ID and the receipt beside the user. Source: Vercel documentation, System environment variables, read on .
Vercel setup

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/esigncomply.txt/route.ts 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.

Copy-paste prompt

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 tool
Prompt: Esign Comply clickwrap on Vercel
Add 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.md
3 things to watch

What 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_ENV is production on a preview, while its key is a test key. Compare livemode with VERCEL_ENV === "production". In a local test with VERCEL_ENV set to production and a test key, the confirm route refused the test record with 409.

  • 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://myapp-git-main-acme.vercel.app was refused with domain_mismatch, and accepted once that host was a test origin of the domain. Use the branch URL, which stays the same across commits.

Verifiable

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, and GET /v1/records/{id}/receipt returns it again.

  • 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.

Recordrec_Z4m8
simple · L1
RecordedWritten durably, receipt signed with ES256
TimestampedExternal RFC 3161 token over the record hash
AnchoredPublic anchor pending
Checkbox changed by a trusted user eventobserved
Terms of Service, version dv_3kT9observed
Server time 2026-11-21T15:03:20.291Zobserved
Signer email dana@example.orgasserted
record_hash sha256:5be7…example record

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/esigncomply.txt, 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.

Working with an AI tool? This page is also available as Markdown: /vercel.md