# Add e-signatures and clickwrap to SolidStart

> Add e-signatures and clickwrap to SolidStart with esigncomply in API routes, useSession for pinned versions and @esigncomply/browser in onMount. Tested code.

Source: https://esigncomply.com/solidstart

Stack · SolidStart

To add e-signatures and clickwrap to SolidStart, install `esigncomply` and `@esigncomply/browser`. An API route creates the session with the secret key and keeps the pinned versions in an encrypted cookie from `useSession`. The page attaches the browser SDK in `onMount`, and a second route confirms the record. Esign Comply seals each acceptance as an independent record anyone can verify.

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/solidstart)

`npm install esigncomply @esigncomply/browser`

[SolidStart quickstart](https://esigncomply.com/docs/quickstart/solidstart)

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

Last updated November 26, 2026

Run in SolidStart before publishing

**API route**

`src/routes/api/ceremony.ts`

```ts
// src/routes/api/ceremony.ts
import type { APIEvent } from "@solidjs/start/server";
import { DOCUMENTS, esc, signer, signupSession } from "~/lib/esigncomply";

// Step 4: create the session with the secret key. The browser gets the client token only.
export async function POST({ request }: APIEvent) {
  // 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: session, 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 cookie = await signupSession();
  await cookie.update({ 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 });
}
```

**Page**

src/routes/signup.tsx (excerpt)

```tsx
// One session per page load.
onMount(() => void start());
onCleanup(() => ceremony?.destroy());

async function start() {
  try {
    // Your API route creates the session and returns { clientToken, apiUrl, documents }. Never the secret key.
    const response = await fetch("/api/ceremony", { method: "POST" });
    if (!response.ok) throw new Error("We could not start the signup. Reload the page to try again.");
    const session = await response.json();

    ceremony = await EsignComply.attach({ clientToken: session.clientToken, apiUrl: session.apiUrl });
    ceremony.on("change", ({ remainingSteps }) => {
      setCanComplete(!remainingSteps.some((step) => step !== "signature.applied"));
    });

    // Point each link at the exact version this session pinned. Solid has changed both addresses when the setter returns.
    setVersions(session.documents.map((document: { version_id: string }) => document.version_id));
    await ceremony.presentDocument({ versionId: versions()[0], mode: "hyperlink", link: termsLink });
    await ceremony.presentDocument({ versionId: versions()[1], mode: "hyperlink", link: privacyLink });
    await ceremony.observeAssent({ region: assent, checkbox, submit }); // region: notice, links, checkbox, button
    setReady(true);
```

**Session cookie**

src/lib/esigncomply.ts (excerpt)

```ts
// Server-owned state: the signer ID and the version IDs this server pinned, in a cookie that
// SolidStart encrypts with SESSION_SECRET. The browser cannot read it or change it.
export function signupSession() {
  return useSession<{ signerId?: string; versionIds?: string[] }>({
    name: "signup",
    password: process.env.SESSION_SECRET!,
  });
}
```

**Server function**

src/routes/legal/\[slug\].tsx (excerpt)

```tsx
const getDocument = query(async (slug: string, version: string) => {
  "use server";
  const documentId = DOCUMENTS[slug];
  if (!documentId) return null;
  const { data, error } = await esc.documents.versions.getContent(documentId, version || "current");
  if (error || !data.html) return null;
  return { versionId: data.version_id, html: data.html };
}, "legal-document");

export default function LegalDocument() {
  const params = useParams();
  const [search] = useSearchParams();
  // deferStream: the server waits for the document before it sends the page, so the HTML carries the text.
  const document = createAsync(() => getDocument(params.slug ?? "", String(search.v ?? "")), { deferStream: true });
```

Integrate with SolidStart

## How do you integrate Esign Comply with SolidStart?

In SolidStart a file under `src/routes` that exports `POST` is an API route, and the key stays there and inside functions marked `"use server"`. `useSession` from `@solidjs/start/http` keeps the pinned versions in an encrypted cookie. A route component also runs on the server, so the page attaches the browser SDK in `onMount`.

SolidStart v2 builds a full-stack app on top of Solid v1 and Vite v8+.

Source: [SolidStart v2 documentation, Overview](https://v1.solidjs.com/solid-start/v2), read on November 26, 2026.

[SolidStart quickstart](https://esigncomply.com/docs/quickstart/solidstart) · [All stacks](https://esigncomply.com/stacks)

Where each part lives in SolidStart

- **API route** · `src/routes/api/ceremony.ts`
- **Page** · `src/routes/signup.tsx`
- **Session cookie** · `src/lib/esigncomply.ts`
- **Server function** · `src/routes/legal/[slug].tsx`

Run on 2026-11-26 with SolidStart 2.2.3 (Solid 1.9.20, Solid Router 1.0.3, Vite 8.3.8, Nitro 3.0.260610-beta), esigncomply 1.0.4 and @esigncomply/browser 1.0.4 on Node.js 24.22.1, under vite dev (the conformance check from esigncomply 1.0.4) and as the built Node.js server (one ceremony), against the API in test mode.

Copy-paste prompt

## What prompt adds Esign Comply clickwrap to a SolidStart 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 SolidStart, 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 SolidStart

```
Add Esign Comply clickwrap to my SolidStart 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/solidstart.md (the steps and the tested code for SolidStart)
- https://esigncomply.com/setup.md (the order of API calls)
- https://esigncomply.com/auth.md (how to handle the keys)

SolidStart facts
- This is SolidStart 2: @solidjs/start 2 on Solid 1, with Vite and Nitro, configured in vite.config.ts. It is not the Solid 2.0 fullstack template of create-solid: do not use @solidjs/vite-plugin start mode or Solid 2 APIs.
- Packages (the only ones that exist): esigncomply (server code, Node.js 20.19 or later) and @esigncomply/browser (the page). There is no Solid package.
- Create the client in one module that starts with import "server-only". Import it only from API routes and from inside functions marked "use server". The build fails when a component reaches it any other way.
- The secret key is in ESIGNCOMPLY_API_KEY in .env. Read it from process.env in server code only. Never give it a VITE_ prefix and never read it in a component.
- Server SDK calls return { data, error } and do not throw. Check error every time.
- Keep the signer ID and the pinned version IDs in the encrypted cookie from useSession (@solidjs/start/http). The password is SESSION_SECRET, at least 32 characters.
- A route component also runs on the server. Call fetch and EsignComply.attach inside onMount only. The form is in the server HTML before the script loads: keep the checkbox disabled until observeAssent has resolved.
- The document pages load their text with createAsync and { deferStream: true }. Without it the page is streamed, and the HTML that arrives first has no document in it.
- Restart vite dev after you add a route file. The built server does not read .env.

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. src/routes/api/ceremony.ts (POST): create the session with esc.sessions.create and an Idempotency-Key, save the signer ID and the pinned version IDs with useSession, and return only clientToken, apiUrl and documents.
4. src/routes/legal/[slug].tsx: a query whose function is marked "use server" loads the registered version from esc.documents.versions.getContent, and the page renders it inside <article data-esc-document> with innerHTML, unmodified.
5. src/routes/signup.tsx: in onMount, EsignComply.attach({ clientToken, apiUrl }), presentDocument for each link, observeAssent({ region, checkbox, submit }) with ref elements, then ceremony.complete() in the submit handler. The checkbox has no checked attribute.
6. src/routes/api/signup/confirm.ts (POST): 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 encrypted cookie. 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 in SolidStart?

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

- **A streamed document page has no document in its first HTML**

  SolidStart streams a page whose data is still loading, and the browser SDK reads a linked document page as HTML without running scripts. In the test on SolidStart 2.2.3 the `document.presented` event then carried no hash of the page. With `deferStream: true` on `createAsync` it carried the hash of the registered version.

  Source: [Solid Router documentation, createAsync](https://v1.solidjs.com/solid-router/reference/data-apis/create-async), read on November 26, 2026.

- **create-solid offers Solid 2.0 first, and that is not SolidStart**

  On 2026-11-26 `npm init solid@latest` listed Solid 2.0 before SolidStart (Solid 1.x). Solid's documentation says the start mode behind the Solid 2.0 templates is not SolidStart and does not provide its runtime. This page was run on SolidStart 2.2.3: choose SolidStart and version 2, or pass `--solidstart --v2`.

  Source: [Solid documentation, From SolidStart](https://docs.solidjs.com/migration/from-solid-start), read on November 26, 2026.

- **A route file added while vite dev runs answers 404**

  Each of the three times it was tried on SolidStart 2.2.3, a file added under `src/routes` while `vite dev` ran was answered by the catch-all page with `404`: an API route, a page, and a page again. The same address answered `200` after a restart. Restart the dev server after you add the routes of the quickstart.

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

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

- Quickstart

  **[SolidStart quickstart](https://esigncomply.com/docs/quickstart/solidstart)**

  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 SolidStart?

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

### Is there an Esign Comply SDK for SolidStart?

Yes, the two JavaScript packages, and no Solid bindings. API routes and server functions use `esigncomply`, and the page calls `@esigncomply/browser` directly in `onMount`. The browser SDK is headless, so it attaches to the markup you wrote.

### Where do I create the session in SolidStart?

In an API route, for example `src/routes/api/ceremony.ts`, with `esc.sessions.create`. The client lives in a module that starts with `import "server-only"`, and the route returns only the client token, the API URL and the pinned documents.

### Does this code run on the Solid 2.0 fullstack template?

No. It was run on SolidStart 2.2.3, which runs on Solid 1. The Solid 2.0 templates use the start mode of `@solidjs/vite-plugin`, which Solid's documentation says is not SolidStart, so the imports from `@solidjs/start` do not exist there. The two API calls are the same on every stack.

### What does "use server" keep out of the browser?

The body of the function and the imports only it uses. In the test, the module `vite dev` sent to the browser held a reference with an ID in place of the function, the import of the server module was gone, and the built browser files did not contain `getContent`.

### What happens when SESSION_SECRET is missing?

The session route answers `500`. In the test, the built server started without `SESSION_SECRET` logged `Empty password`, and with a value shorter than 32 characters it logged `Password string too short`. `vite dev` reads the value from `.env`, and the built server only from its environment.

### Other stacks

- [SvelteKit](https://esigncomply.com/sveltekit)
- [Nuxt](https://esigncomply.com/nuxt)
- [React](https://esigncomply.com/react)

### Platforms used with SolidStart

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

[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 signup in your own SolidStart app. Leave the record to us.

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

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

SolidStart is a trademark of its owner. Esign Comply is not affiliated with it. What this page says about SolidStart is from SolidStart's documentation or from a test run, as marked, on November 26, 2026. `/solidstart.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.
