Skip to content
Stack · React Router

Add e-signatures and clickwrap to React Router

To add e-signatures and clickwrap to React Router in framework mode, install esigncomply, @esigncomply/react and @esigncomply/browser. A resource route creates the session with the secret key and keeps the pinned versions in a signed cookie session. The React hooks attach to your own checkbox and button, and a second resource route confirms the record. Esign Comply seals each acceptance.

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
React Router quickstart

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

Last updated

Run in React Router before publishing
app/routes/api.ceremony.ts
// app/routes/api.ceremony.ts
import { DOCUMENTS, esc, signer } from "~/lib/esigncomply.server";
import { commitSession, getSession } from "~/sessions.server";
import type { Route } from "./+types/api.ceremony";

// A resource route: no default export, so React Router serves what the action returns.
// Step 4: create the session with the secret key. The browser gets the client token only.
export async function action({ request }: Route.ActionArgs) {
  // The page that runs the ceremony: the origin the browser reports, plus its path.
  const origin = request.headers.get("origin") ?? new URL(request.url).origin;

  const { data: created, error } = await esc.sessions.create(
    {
      profile: process.env.ESIGNCOMPLY_PROFILE_ID!,
      signer,
      documents: [
        { document: DOCUMENTS.terms!, version: "current" },
        { document: DOCUMENTS.privacy!, version: "current" },
      ],
      context: { url: `${origin}/signup`, locale: "en-US", purpose: "account_signup" },
    },
    { idempotencyKey: `signup-${signer.external_id}-${crypto.randomUUID()}` },
  );
  if (error) return Response.json({ error: error.code }, { status: 502 });

  const session = await getSession(request.headers.get("Cookie"));
  session.set("signerId", signer.external_id);
  session.set(
    "versionIds",
    created.documents.map((d) => d.version_id),
  );
  return Response.json(
    { clientToken: created.client_token, apiUrl: created.api_url, documents: created.documents },
    { headers: { "Set-Cookie": await commitSession(session) } },
  );
}
Integrate with React Router

How do you integrate Esign Comply with React Router?

In framework mode a route module with an action and no default export is a resource route, and React Router removes loader and action from the code it sends to the browser. The key stays in a .server.ts module and the pinned versions in a signed cookie session. The page is React, so the @esigncomply/react hooks attach the ceremony.

React Router is a multi-strategy router for React. You can use it maximally as a React framework or as minimally as you want.

Source: React Router documentation, Home, read on .
Where each part lives in React Router
  • Resource routeapp/routes/api.ceremony.ts
  • Pageapp/routes/signup.tsx
  • Cookie sessionapp/sessions.server.ts
  • routes.tsapp/routes.ts

Run on 2026-11-26 with React Router 8.5.3 in framework mode (@react-router/dev, @react-router/node and @react-router/serve 8.5.3, React 19.3.1, Vite 8.3.8), in the app that npx create-react-router@latest makes, esigncomply 1.0.4, @esigncomply/react 1.0.1 and @esigncomply/browser 1.0.4 on Node.js 24.22.1, under react-router dev (the conformance check from esigncomply 1.0.4) and as the built server under react-router-serve (one ceremony), against the API in test mode.

Copy-paste prompt

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

React Router facts
- This is React Router in framework mode: the @react-router/dev Vite plugin, routes declared in app/routes.ts, route modules with loader and action. Packages from Esign Comply (the only ones that exist): esigncomply (server code, Node.js 20.19 or later), @esigncomply/react (hooks, React 18 or later) and @esigncomply/browser.
- Keep the client in a file named *.server.ts. The build fails with "Server-only module referenced by client" when a component reaches it. Import it only in loader and action functions.
- POST /api/ceremony and POST /api/signup/confirm are resource routes: route modules with an action and no default export, registered in app/routes.ts. Return Response.json from them.
- What a loader returns is sent to the browser and is in the page's HTML. Never return a secret from one. Do not create the session in a loader: a Link with prefetch="intent" runs the loader on hover.
- Keep the signer ID and the pinned version IDs in a cookie session from createCookieSessionStorage (app/sessions.server.ts), signed with SESSION_SECRET. Send the Set-Cookie header from commitSession with the response. The cookie is signed, not encrypted: put nothing secret in it.
- Server SDK calls return { data, error } and do not throw. Check error every time.
- The default client entry wraps the app in StrictMode, so effects run twice in development. Request the session once per mount, from a promise kept in a ref.
- The form is in the server HTML before the page hydrates: keep the checkbox disabled until observeAssent has resolved.
- react-router dev loads .env into process.env. react-router-serve does not.

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. app/routes/api.ceremony.ts (action): create the session with esc.sessions.create and an Idempotency-Key, save the signer ID and the pinned version IDs in the cookie session, and return only clientToken, apiUrl and documents.
4. app/routes/legal.tsx: the loader reads the registered version with esc.documents.versions.getContent, and the component renders it inside <article data-esc-document> with dangerouslySetInnerHTML, unmodified.
5. app/routes/signup.tsx: 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. app/routes/api.signup.confirm.ts (action): read the record with esc.records.get and require: status is "recorded", "timestamped" or "anchored"; livemode is as expected; the signer ID and version IDs equal the ones in the cookie session. 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 Router?

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

  • 01

    A Link with prefetch runs the loader before any click

    In the test on React Router 8.5.3, hovering a Link with prefetch="intent" requested the route's .data address, and its loader ran on the server. A plain Link did not. A marker that loader returned was in the page's HTML twice. The quickstart creates the session in a resource route, and its only loader returns the document.

  • 02

    The session cookie is signed, not encrypted

    React Router's documentation says a cookie with secrets is stored and verified in a way that ensures its integrity. In the test the value decoded to the signer ID and the version IDs in plain JSON, and a cookie with a changed payload and the old signature was refused with 409. Put nothing secret in the session.

    Source: React Router documentation, Sessions and Cookies, read on .
  • 03

    react-router-serve does not read the .env file that react-router dev reads

    In the test react-router dev loaded .env into process.env. The built server under react-router-serve did not: started with no variables, the session route answered 502 with missing_api_key. With the key and no SESSION_SECRET it answered 500 and logged Zero-length key is not supported. Set both on the host.

Verifiable

What does Esign Comply record for a signature in React Router?

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

Is there an Esign Comply SDK for React Router?

Yes, the three JavaScript packages, and nothing specific to the router. Resource routes and loaders use esigncomply, and the page uses the @esigncomply/react hooks over @esigncomply/browser. The hooks ship no components, so you build the form.

Where do I create the session in React Router?

In the action of a resource route, for example app/routes/api.ceremony.ts, with esc.sessions.create. The client lives in a .server.ts module, and the route returns only the client token, the API URL and the pinned documents, with the session cookie in Set-Cookie.

Does this page cover React Router as a library, or Remix?

No, it covers framework mode only. An app that uses React Router as a library, in declarative or data mode, has no server from the framework: follow the React page at /react. The page at /remix is about Remix 3, a different framework that is not React. An app that came from Remix 2 belongs here.

Why are the endpoints resource routes and not route actions?

Because they are called by address and answer with JSON: the page posts to them with fetch, and the conformance check posts a made-up record ID to the confirm route. In the test a POST with another site's Origin was answered 400 by the action of a route with a component, and reached the resource route.

What stops a component from importing the .server module?

The build. In the test react-router build ended with Server-only module referenced by client when a route component imported esigncomply.server.ts. Under react-router dev the server rendered that page once, and the browser's request for the route module was answered 500 with the same message.

Build the signup in your own React Router app. Leave the record to us.

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

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

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