Skip to content
Stack · React

Add e-signatures and clickwrap to React

To add e-signatures and clickwrap to React, install @esigncomply/react and @esigncomply/browser. The useCeremony and useDocument hooks attach to the checkbox, links and button you built. Because React runs in the browser, a server route creates the session with the secret key and another confirms the record. Esign Comply seals it as an independent record.

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/react @esigncomply/browser esigncomply
React quickstart

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

Last updated

Run in React before publishing
src/Signup.jsx (excerpt)
let ceremonyRequest;
function requestCeremony() {
  ceremonyRequest ??= fetch("/api/ceremony", { method: "POST" }).then((response) => response.json());
  return ceremonyRequest;
}

// Document links are underlined and differ from the text around them by at least 3 to 1 (rule CR-05).
const LINK = { color: "#0b57d0", textDecoration: "underline" };

export function Signup() {
  // { clientToken, apiUrl, documents } from your server. Never the secret key.
  const [session, setSession] = useState(null);
  useEffect(() => {
    let mounted = true;
    requestCeremony().then((value) => mounted && setSession(value));
    return () => {
      mounted = false;
    };
  }, []);

  const { ceremony, canComplete, error } = useCeremony({ clientToken: session?.clientToken, apiUrl: session?.apiUrl });
  const [terms, privacy] = session?.documents ?? [];
  const tos = useDocument(ceremony, { versionId: terms?.version_id, mode: "hyperlink" });
  const notice = useDocument(ceremony, { versionId: privacy?.version_id, mode: "hyperlink" });

  const assentRef = useRef(null);
  const checkboxRef = useRef(null);
  const submitRef = useRef(null);
  const [ready, setReady] = useState(false); // true once the SDK observes the checkbox
  const [message, setMessage] = useState("");

  // Observe the assent controls once both documents are presented.
  useEffect(() => {
    if (!ceremony || !tos.presented || !notice.presented) return;
    void ceremony
      .observeAssent({
        region: assentRef.current, // notice, links, checkbox, button
        checkbox: checkboxRef.current,
        submit: submitRef.current,
      })
      .then(() => setReady(true));
  }, [ceremony, tos.presented, notice.presented]);
Integrate with React

How do you integrate Esign Comply with React?

A React app is the browser half of the integration. The hooks render nothing: useCeremony attaches to the session and useDocument reports each document link. The secret key cannot live in a bundle, so the session comes from a server route, requested once per page load from a promise that sits outside the component.

In development, StrictMode makes components re-run Effects an extra time to find bugs caused by missing Effect cleanup.

Source: React documentation, StrictMode, read on .
Where each part lives in React
  • React formsrc/Signup.jsx
  • Server routeserver/index.js
  • Vite proxyvite.config.js

Run on 2026-11-26 with React 19.3.1, Vite 8.3.8, @esigncomply/react 1.0.1, @esigncomply/browser 1.0.4, esigncomply 1.0.4 and the conformance check from esigncomply 1.0.4 on Node.js 24.22.1, against the API in test mode.

Copy-paste prompt

What prompt adds Esign Comply clickwrap to a React 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 in React, 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 in React
Add Esign Comply clickwrap to my React app: 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/react.md (the steps and the tested code for React)
- https://esigncomply.com/setup.md (the order of API calls)
- https://esigncomply.com/auth.md (how to handle the keys)

React facts
- Packages (the only ones that exist): @esigncomply/react (hooks, React 18 or later) and @esigncomply/browser for the page; esigncomply (Node.js 20.19 or later) for the server.
- React runs in the browser, so the secret key cannot live in the React app. It is in ESIGNCOMPLY_API_KEY on a server. Never give it a VITE_ prefix: Vite puts every VITE_ variable into the bundle.
- React runs effects twice in development under StrictMode. Request the session once per page load, from a promise kept outside the component.
- The form is on screen before the hooks have a session: render the checkbox disabled and enable it when observeAssent has resolved.
- The page and the document pages must share one origin. In development, proxy /api and /legal from Vite to the server.

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. Server: POST /api/ceremony creates the session with esc.sessions.create and an Idempotency-Key, saves the signer ID and the pinned version IDs in server-owned state, and returns only clientToken, apiUrl and documents.
4. Server: GET /legal/terms and /legal/privacy render the registered version from esc.documents.versions.getContent inside <article data-esc-document>, unmodified.
5. React: useCeremony({ clientToken, apiUrl }), useDocument for each link, ceremony.observeAssent({ region, checkbox, submit }) from an effect, then ceremony.complete() in the submit handler. The checkbox is uncontrolled and starts unchecked.
6. Server: POST /api/signup/confirm reads the record with esc.records.get and requires: status is "recorded", "timestamped" or "anchored"; livemode is as expected; 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:5173/signup --callback http://localhost:5173/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 in React?

These are specific to React. Each one was seen while the quickstart's code was run, or is in React's own documentation.

  • 01

    StrictMode runs the session request twice

    A fetch inside useEffect runs twice in development. In a test with React 19.3.1, one page load sent two POST /api/ceremony requests and created two sessions. With the request kept in a promise at module level it sent one. The useCeremony hook itself attaches once: each session shows a single client.attached event.

  • 02

    Vite ships every VITE_ variable to the browser

    Never name the key VITE_ESIGNCOMPLY_API_KEY. In a test build with Vite 8.3.8, a variable that started with VITE_ was in the bundle and ESIGNCOMPLY_API_KEY from the same .env file was not. Only the server reads the key.

  • 03

    The document pages must share the page's origin

    For a link on the same origin the browser SDK reads the linked page and compares its text with the registered version. In development, proxy /legal to your server beside /api. Without the proxy, Vite answers /legal/terms with the app's own HTML and there is no document to compare.

Verifiable

What does Esign Comply record for a signature in React?

The same record on every stack and platform. Your React 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 in React

Is there an Esign Comply SDK for React?

Yes. @esigncomply/react is a thin layer of hooks over @esigncomply/browser, for React 18 or later. It exports useCeremony and useDocument and ships no visual components. Your server uses esigncomply, or plain HTTPS calls in another language.

Where do I create the session in React?

Not in React. The session is created on a server with the secret key, and the React app receives only the client token, the API URL and the pinned documents. Any backend can carry the route: the quickstart uses one Node.js file.

Does useCeremony attach twice under StrictMode?

No. The hook attaches once for each pair of client token and API URL, and components that pass the same pair share the attachment. In the test run each session recorded client.attached once, although StrictMode ran the effect twice.

Should the acceptance checkbox be a controlled input?

Leave it uncontrolled, or control it with state that starts false. The SDK reports the control as it finds it, so a box that renders checked, or one your code ticks, is recorded that way and fails the rule on affirmative assent.

Can I use the hooks without Vite?

Yes. The hooks are plain React and need only the client token. The quickstart was run with Vite 8.3.8, and the Next.js quickstart uses the same hooks in the App Router. What changes between setups is where the server routes live.

Build the form in React. Leave the record to us.

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

React is a trademark of its owner. Esign Comply is not affiliated with it. What this page says about React is from React's documentation or from a test run, as marked, on . /react.md is this page as Markdown.

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