Add e-signatures and clickwrap to Qwik
To add e-signatures and clickwrap to Qwik, install esigncomply and @esigncomply/browser. A Qwik City endpoint creates the session with the secret key, a visible task attaches the browser SDK to your own checkbox and button, and a second endpoint 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.
$npm install esigncomply @esigncomply/browserFree plan: 10 live signatures a month and a full test mode. No card required.
Last updated
// src/routes/api/ceremony/index.ts import type { RequestHandler } from "@builder.io/qwik-city"; import { documentId, esc, pinned, signer } from "~/lib/esigncomply"; // An index.ts with no component is an endpoint. onPost runs on the server only. // Step 4: create the session with the secret key. The browser gets the client token only. export const onPost: RequestHandler = async ({ env, request, url, json }) => { // The page that runs the ceremony: the origin the browser reports, plus its path. // Qwik City serves pages with a trailing slash unless you turn that off. const origin = request.headers.get("origin") ?? url.origin; const { data: session, error } = await esc(env).sessions.create( { profile: env.get("ESIGNCOMPLY_PROFILE_ID")!, signer, documents: [ { document: documentId(env, "terms")!, version: "current" }, { document: documentId(env, "privacy")!, version: "current" }, ], context: { url: `${origin}/signup/`, locale: "en-US", purpose: "account_signup" }, }, { idempotencyKey: `signup-${signer.external_id}-${crypto.randomUUID()}` }, ); if (error) { json(502, { error: error.code }); return; } pinned.set( signer.external_id, session.documents.map((d) => d.version_id), ); json(200, { clientToken: session.client_token, apiUrl: session.api_url, documents: session.documents }); };
// Qwik does not hydrate: no component code runs in the browser until something asks for it. // A visible task asks for it. This one runs once, in the browser only. One session per page load. // eslint-disable-next-line qwik/no-use-visible-task useVisibleTask$( async ({ cleanup }) => { try { // Your endpoint 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(); const attached = await EsignComply.attach({ clientToken: session.clientToken, apiUrl: session.apiUrl }); cleanup(() => attached.destroy()); attached.on("change", ({ remainingSteps }) => { canComplete.value = !remainingSteps.some((step) => step !== "signature.applied"); }); // Point each link at the exact version this session pinned, then hand over to the task below. versions.value = session.documents.map((document: { version_id: string }) => document.version_id); ceremony.value = noSerialize(attached); } catch (error) { message.value = error instanceof Error ? error.message : "Something went wrong."; } }, { strategy: "document-ready" }, ); // Runs again when the ceremony is set, after Qwik has written both addresses to the page. // eslint-disable-next-line qwik/no-use-visible-task useVisibleTask$(async ({ track }) => { const attached = track(() => ceremony.value); if (!attached) return; try { await attached.presentDocument({ versionId: versions.value[0], mode: "hyperlink", link: termsLink.value! }); await attached.presentDocument({ versionId: versions.value[1], mode: "hyperlink", link: privacyLink.value! }); // region: notice, links, checkbox, button await attached.observeAssent({ region: assent.value!, checkbox: checkbox.value!, submit: submit.value! }); ready.value = true;
// /legal/terms/?v=dv_... loads one registered version. A routeLoader$ runs on the server only. // What it returns goes to the browser, in the page and as JSON at the route's q-data.json: return the document, never the key. export const useLegalDocument = routeLoader$(async ({ env, params, query, status }) => { const id = documentId(env, params.slug); const { data, error } = id ? await esc(env).documents.versions.getContent(id, query.get("v") || "current") : { data: null, error: null }; if (error || !data?.html) { status(404); return null; } return { versionId: data.version_id, html: data.html }; });
// Server variables come from the request event of an endpoint, a routeLoader$, a routeAction$ or a server$. // They are not in import.meta.env, which is for PUBLIC_ values that ship to the browser. type Env = RequestEventBase["env"]; let client: EsignComply | undefined; export function esc(env: Env) { return (client ??= new EsignComply(env.get("ESIGNCOMPLY_API_KEY"), { baseUrl: env.get("ESIGNCOMPLY_API_URL") })); }
How do you integrate Esign Comply with Qwik?
In Qwik City an index.ts that exports onPost is an endpoint, and it reads the key from env.get on the request event. Qwik does not hydrate, so nothing on the page runs in the browser until a visible task asks for it. The ceremony lives in a signal, because every $ closure is loaded on its own.
Qwik is a new kind of web framework that can deliver instant loading web applications at any size or complexity.
Source: Qwik documentation, Overview, read on .- Endpointsrc/routes/api/ceremony/index.ts
- Pagesrc/routes/signup/index.tsx
- routeLoader$src/routes/legal/[slug]/index.tsx
- Server modulesrc/lib/esigncomply.ts
Run on 2026-11-26 with Qwik 1.20.4 and Qwik City 1.20.4 (Vite 7.3.7), in the app that npm create qwik@latest makes from its empty starter, with the Express adapter (express 4.22.0) for the Node.js server, 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.
What prompt adds Esign Comply clickwrap to a Qwik 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 Qwik, 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 toolAdd Esign Comply clickwrap to my Qwik 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/qwik.md (the steps and the tested code for Qwik)
- https://esigncomply.com/setup.md (the order of API calls)
- https://esigncomply.com/auth.md (how to handle the keys)
Qwik facts
- This is Qwik 1 with Qwik City: @builder.io/qwik and @builder.io/qwik-city, with Vite. Packages from Esign Comply (the only ones that exist): esigncomply (server code, Node.js 20.19 or later) and @esigncomply/browser (the page). There is no Qwik package.
- Server code is an endpoint (onPost in an index.ts under src/routes), a routeLoader$, a routeAction$ or a server$. Read the key there with env.get("ESIGNCOMPLY_API_KEY") from the request event. It is not in import.meta.env. Never give it a PUBLIC_ prefix.
- What a routeLoader$ returns goes to the browser, and anyone can request it at the route's q-data.json. Never return a secret from one. Do not create the session in a routeLoader$: a Link to the page fetches its loader data before any click.
- Server SDK calls return { data, error } and do not throw. Check error every time.
- Qwik does not hydrate. Component code runs in the browser only when something asks for it: call fetch and EsignComply.attach inside useVisibleTask$ with { strategy: "document-ready" }.
- Every $ closure is loaded on its own and gets copies of the constants it captures. Keep the ceremony in a signal, wrapped in noSerialize. Never in a let variable.
- The form needs preventdefault:submit. event.preventDefault() inside onSubmit$ runs too late.
- The form is in the server HTML before any script runs: keep the checkbox disabled until observeAssent has resolved.
- Qwik City serves pages with a trailing slash: the page is /signup/ and the document links are /legal/terms/?v=... and /legal/privacy/?v=...
- The built server checks the Origin header of every POST. A POST with no Origin header, such as a webhook, is answered 403 before the handler runs.
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/index.ts (onPost): create the session with esc(env).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. src/routes/legal/[slug]/index.tsx: a routeLoader$ loads the registered version from esc(env).documents.versions.getContent, and the component renders it inside <article data-esc-document> with dangerouslySetInnerHTML, unmodified.
5. src/routes/signup/index.tsx: in a visible task, EsignComply.attach({ clientToken, apiUrl }); in a second visible task that tracks the ceremony, presentDocument for each link and observeAssent({ region, checkbox, submit }) with the elements of ref signals; then ceremony.complete() in onSubmit$. The checkbox has no checked attribute.
6. src/routes/api/signup/confirm/index.ts (onPost): read the record with esc(env).records.get and require: 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.mdWhat goes wrong when you add e-signatures in Qwik?
These are specific to Qwik. Each one was seen while the quickstart's code was run, or is in Qwik's own documentation.
- 01
The built server answers 403 to a POST with no Origin header
Qwik's documentation says Qwik City checks the
Source: Qwik documentation, Node.js deployments, read on .Originheader on every POST, PUT, PATCH and DELETE request. In the test on Qwik City 1.20.4 the built Express server answered acurlrequest to the confirm endpoint403before the endpoint ran, andvite devanswered the same request409. A webhook is a request of that kind. - 02
A Link to a page runs its routeLoader$ before any click
In the test on the built server, a page that held a
Linkto another route requested that route'sq-data.jsonas soon as the link was visible, and the loader ran on the server. Undervite devthe request went out on hover. The quickstart creates the session through an endpoint, from a task on the signup page itself. - 03
The form can be used before any Qwik code has run
Qwik resumes instead of hydrating: the form is working HTML at once, and component code runs only when a task or an event asks for it. On the built server the SDK watched the box 0.9 to 2 seconds after it was visible. In a test without
Source: Qwik documentation, Resumable, read on .disabled, a box ticked in that time stayed ticked and raised aCR-01finding.
Where are the Qwik quickstart and the API reference?
Start with the quickstart: it carries every file this page excerpts, in the order you write them.
- QuickstartQwik quickstartStep by step, from install to your first sealed test record, with every file and the output of each step.Open
- ReferenceAPI referenceEvery endpoint, field and error code. Sessions, records and documents are the three this page uses.Open
- GuideServer confirmationThe one place access is granted: what to compare, and the webhook that backs the check up.Open
What does Esign Comply record for a signature in Qwik?
The same record on every stack and platform. Your Qwik 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, andGET /v1returns it again./records /{id} /receipt 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.
Questions about e-signatures in Qwik
Is there an Esign Comply SDK for Qwik?
Yes, the two JavaScript packages, and no Qwik bindings. Endpoints and loaders use esigncomply, and the page calls @esigncomply/browser directly inside useVisibleTask$. The browser SDK is headless, so it attaches to the markup you wrote.
Where do I create the session in Qwik?
In a Qwik City endpoint, for example src/routes, with esc(env).sessions.create inside onPost. The key comes from env.get on the request event, and the endpoint returns only the client token, the API URL and the pinned documents.
Why is the ceremony kept in a signal with noSerialize?
Because every $ closure is loaded on its own and gets copies of the constants it captures. In the test, a ceremony kept in a let variable stopped the task with Assignment to constant variable, and the submit handler saw undefined. A signal is shared, and noSerialize keeps the object out of the page state.
Why does the form need preventdefault:submit?
Because Qwik loads the handler on demand, and by then the browser has acted. In the test, a handler that called event.preventDefault() ran, and the browser still submitted the form and loaded the page again. The attribute stops the submit without waiting for any handler.
Where can server code read the key in Qwik?
From env.get on the request event of an endpoint, a routeLoader$, a routeAction$ or a server$. In the test import.meta.env did not hold the key on either side. The built Express server read .env from the folder it was started in, and did not read .env.local.
Build the signup in your own Qwik app. Leave the record to us.
Free plan: 10 live signatures a month and a full test mode. No card required.
Qwik is a trademark of its owner. Esign Comply is not affiliated with it. What this page says about Qwik is from Qwik's documentation or from a test run, as marked, on . /qwik.md is this page as Markdown.