# Add e-signatures and clickwrap to React

> Add e-signatures and clickwrap to a React app with the @esigncomply/react hooks, useCeremony and useDocument, and a server route that holds the secret key.

Source: https://esigncomply.com/react

Stack · 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.

[Get an API key](https://esigncomply.com/signup) · [Read the docs](https://esigncomply.com/docs/quickstart/react)

`npm install @esigncomply/react @esigncomply/browser esigncomply`

[React quickstart](https://esigncomply.com/docs/quickstart/react)

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

Last updated November 26, 2026

Run in React before publishing

**React form**

src/Signup.jsx (excerpt)

```jsx
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]);
```

**Server route**

server/index.js (excerpt)

```js
// Step 4: create the session with the secret key. The browser gets the client token only.
if (req.method === "POST" && url.pathname === "/api/ceremony") {
  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 page that runs the ceremony: the origin the browser reports, plus its path.
      context: { url: `${req.headers.origin ?? url.origin}/signup`, locale: "en-US", purpose: "account_signup" },
    },
    { idempotencyKey: `signup-${signer.external_id}-${randomUUID()}` },
  );
  if (error) return json(res, 502, { error: error.code });
  pinned.set(signer.external_id, session.documents.map((d) => d.version_id));
  return json(res, 200, { clientToken: session.client_token, apiUrl: session.api_url, documents: session.documents });
```

**Vite proxy**

`vite.config.js`

```js
// vite.config.js
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

export default defineConfig({
  plugins: [react()],
  server: {
    // The three server routes live in your backend. In development Vite forwards them,
    // so the page and the document pages share one origin.
    proxy: {
      "/api": "http://localhost:3001",
      "/legal": "http://localhost:3001",
    },
  },
});
```

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](https://react.dev/reference/react/StrictMode), read on November 23, 2026.

[React quickstart](https://esigncomply.com/docs/quickstart/react) · [All stacks](https://esigncomply.com/stacks)

Where each part lives in React

- **React form** · `src/Signup.jsx`
- **Server route** · `server/index.js`
- **Vite proxy** · `vite.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](https://esigncomply.com/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](https://esigncomply.com/product/prompt-generator) writes the long version, with your own document and profile IDs.

[Pages for each AI tool](https://esigncomply.com/build)

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.

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

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

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

## Where are the React quickstart and the API reference?

Start with the quickstart: it carries every file this page excerpts, in the order you write them.

- Quickstart

  **[React quickstart](https://esigncomply.com/docs/quickstart/react)**

  Step by step, from install to your first sealed test record, with every file and the output of each step.

- Reference

  **[API reference](https://esigncomply.com/docs/api)**

  Every endpoint, field and error code. Sessions, records and documents are the three this page uses.

- Guide

  **[Server confirmation](https://esigncomply.com/docs/guides/server-confirmation)**

  The one place access is granted: what to compare, and the webhook that backs the check up.

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](https://esigncomply.com/product/evidence).

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

[How sealing and verification work](https://esigncomply.com/product/evidence) · [Observed and asserted, in the docs](https://esigncomply.com/docs/concepts/observed-and-asserted) · [The offline verifier](https://esigncomply.com/docs/sdk/verify)

Record

`rec_Z4m8`

simple · L1

Recorded

Written durably, receipt signed with ES256

Timestamped

External RFC 3161 token over the record hash

Anchored

Public anchor pending

Checkbox changed by a trusted user event · observed

Terms of Service, version dv_3kT9 · observed

Server time 2026-11-21T15:03:20.291Z · observed

Signer email dana@example.org · asserted

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.

### Other stacks

- [Next.js](https://esigncomply.com/nextjs)
- [React Router](https://esigncomply.com/react-router)
- [Node.js](https://esigncomply.com/nodejs)

### Platforms used with React

- [Supabase](https://esigncomply.com/supabase)
- [Netlify](https://esigncomply.com/netlify)
- [Cloudflare Workers](https://esigncomply.com/cloudflare-workers)

[All stacks](https://esigncomply.com/stacks) · [All platforms](https://esigncomply.com/platforms) · [Clickwrap API](https://esigncomply.com/clickwrap) · [E-signature API](https://esigncomply.com/sign)

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

[Get an API key](https://esigncomply.com/signup) · [Read the docs](https://esigncomply.com/docs/quickstart/react)

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 November 23, 2026. `/react.md` is this page as Markdown.

---

Every page on esigncomply.com has a Markdown version at the same URL plus `.md` (the home page is `https://esigncomply.com/index.md`). https://esigncomply.com/llms.txt lists them.

---

Esign Comply is the e-signature API and clickwrap API for developers who build their own signing flow in their own UI: it supplies the ceremony rules as a generated prompt for AI coding tools, records events in direct browser ceremonies, and seals independent, verifiable evidence.
