Skip to content
DocsMenu

Add e-signatures and clickwrap with Qwik

View as Markdown

Open this page inChatGPTClaudeCursor

To add e-signatures and clickwrap with 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 you can verify.

Follow the steps and each signature your app records is a valid electronic signature under the ESIGN Act, state UETA laws and New York's ESRA, and your clickwrap is built the way courts require: clear notice of the terms, an unmistakable act of assent, and a sealed record of both.

This page is for Qwik 1 with Qwik City, the packages @builder.io/qwik and @builder.io/qwik-city that npm create qwik@latest installs today.

Paste this prompt into Cursor, Claude Code or another AI coding tool to have it build the same integration:

Add 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.md

The rest of this page is the same integration by hand, in eight steps.

Before you start

  • A test API key. Create an account with your email, no card, then choose Create test key in the dashboard. The key is shown once and starts with esc_test_. An AI agent with an agent token creates it with POST /v1/agent/api-keys: see the agent account API.
  • Nothing else from Esign Comply. Test mode works on localhost with no card and no domain, and the Free plan includes it in full.
  • A Qwik app with Qwik City. To start one: npm create qwik@latest, or with no questions npm create qwik@latest empty my-app. This page was run on Qwik 1.20.4 and Qwik City 1.20.4, in the app the second command creates.
  • Node.js 20.19 or later, which the esigncomply package needs. The starter's own engines field allows Node.js 18.17. This page was run on Node.js 24.22.1.
  • curl and jq for steps 2 and 3.

Step 1. Install

Install the server package for the endpoints and the browser SDK for the page:

npm install esigncomply @esigncomply/browser

There is no Qwik package to add. The browser SDK is headless: you write the markup, and it observes it.

Step 2. Set the key

Put the key in .env in the project folder. Qwik City hands server variables to server code through the request event, as env.get("NAME"). When this was tested under vite dev, an endpoint and a routeLoader$ read the key that way, and import.meta.env did not hold it on the server or in the browser. Never give the key a PUBLIC_ prefix: Qwik's documentation says those variables are visible to the client.

# .env (never commit this file)
ESIGNCOMPLY_API_KEY=esc_test_us_...

Load the file into your shell for the commands in steps 2, 3 and 7, then check that the key works:

set -a; . ./.env; set +a
curl -s ${ESIGNCOMPLY_API_URL:-https://esigncomply.com/v1}/usage \
  -H "Authorization: Bearer $ESIGNCOMPLY_API_KEY" | jq '{plan_name, test_events}'
{
  "plan_name": "Free",
  "test_events": {
    "used_this_month": 0,
    "quota_per_month": 500
  }
}

A 401 means the key is wrong or revoked: see invalid_api_key. The rules for handling keys are in /auth.md.

Step 3. Register a document version

Every record pins the exact version of each document by hash, so the documents are registered first. This block registers a Terms of Service and a Privacy Notice with one version each, and creates a profile: the Federal pack, a checkbox with a button, level L1. It is the same for every stack and needs curl and jq.

ESC=${ESIGNCOMPLY_API_URL:-https://esigncomply.com/v1}
KEY="Authorization: Bearer $ESIGNCOMPLY_API_KEY"
JSON="Content-Type: application/json"

# Two sample documents, one version each.
TERMS=$(curl -s $ESC/documents -H "$KEY" -H "$JSON" \
  -d '{"name":"Terms of Service","type":"terms"}' | jq -r .id); sleep 1
curl -s $ESC/documents/$TERMS/versions -H "$KEY" -H "$JSON" \
  -d '{"version_label":"1","language":"en","content":{"format":"markdown","text":"# Terms of Service\n\nThese are sample terms for a test."},"material_change":true}' \
  | jq -r .id; sleep 1
PRIVACY=$(curl -s $ESC/documents -H "$KEY" -H "$JSON" \
  -d '{"name":"Privacy Notice","type":"privacy_notice"}' | jq -r .id); sleep 1
curl -s $ESC/documents/$PRIVACY/versions -H "$KEY" -H "$JSON" \
  -d '{"version_label":"1","language":"en","content":{"format":"markdown","text":"# Privacy Notice\n\nThis is a sample privacy notice for a test."}}' \
  | jq -r .id; sleep 1

# A profile: Federal pack, checkbox plus button, L1.
PROFILE=$(curl -s $ESC/profiles -H "$KEY" -H "$JSON" \
  -d '{"name":"Signup","jurisdictions":["US-FED"],"method":"checkbox","assurance_level":"L1"}' | jq -r .id)

printf 'ESIGNCOMPLY_PROFILE_ID=%s\nESIGNCOMPLY_TERMS_ID=%s\nESIGNCOMPLY_PRIVACY_ID=%s\n' "$PROFILE" "$TERMS" "$PRIVACY"

It prints the two version IDs, then three lines with your own IDs:

dv_YiWs9cmWoVSGp7ALPeZS
dv_bAYeA7QigKUH0iLhPpV7
ESIGNCOMPLY_PROFILE_ID=prof_SPVEgBT8a8Ror3mJ8M99
ESIGNCOMPLY_TERMS_ID=doc_bDgYFndAoC8tkeYibAVy
ESIGNCOMPLY_PRIVACY_ID=doc_mb2hnWKS0Qa7SKtucDW9

Add the three lines to .env. The pauses keep the script under the Free plan's 2 requests per second. Keep the names Terms of Service and Privacy Notice: the notice on your page names each document by its registered name, and rule CR-02 checks that it does. With your own documents, publish the text you already have and change the notice to match. See Documents and Profiles.

Step 4. Create a session on the server

One module holds the client, the test signer and the state the confirmation compares against:

// src/lib/esigncomply.ts
import type { RequestEventBase } from "@builder.io/qwik-city";
import { EsignComply } from "esigncomply";

// 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") }));
}

// The signer. In your app this is the signed-in user, or the account you are about to create.
export const signer = {
  external_id: "user_7c1d",
  email: "dana@example.org",
  name: "Dana Whitfield",
  class: "consumer",
  country: "US",
  region: "US-CA",
} as const;

export function documentId(env: Env, slug: string): string | undefined {
  const names: Record<string, string> = { terms: "ESIGNCOMPLY_TERMS_ID", privacy: "ESIGNCOMPLY_PRIVACY_ID" };
  return names[slug] ? env.get(names[slug]) : undefined;
}

export const SEALED = ["recorded", "timestamped", "anchored"];
// Test records in development, live records where ESIGNCOMPLY_LIVE is "true": production only.
export const live = (env: Env) => env.get("ESIGNCOMPLY_LIVE") === "true";

// Signer ID -> the version IDs this server pinned. Use a table in your database in production.
export const pinned = new Map<string, string[]>();

Two things here are specific to Qwik. The client is built from env, the object Qwik City puts on the request event of an endpoint, a routeLoader$, a routeAction$ and a server$. Its documentation says process.env is an API of Node.js only and should be avoided, so this file never reads it.

And the pinned Map is plain server memory. The request event of Qwik City 1.20.4 has a cookie helper, and its options have nothing that signs or encrypts a value, so the pinned versions do not go there. Both endpoints below read the same Map, under vite dev and in the built server. Under vite dev an edit of this file emptied it, and an edit of an endpoint file did not. Replace it with a table in your database before you run more than one process.

In Qwik City an index.ts under src/routes that exports onPost is an endpoint. This one creates the session and returns three values to the browser: the client token, the API URL and the pinned documents.

// 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 });
};

The signer is a fixed test person here. In your app it is the signed-in user or the account you are about to create. The address in context.url ends in a slash because Qwik City serves pages that way by default: /signup answered 301 to /signup/ in the test. The endpoints answered at both addresses.

Step 5. Attach the ceremony in the browser

The browser SDK renders nothing. It observes the checkbox, the notice, the links and the button of your own markup, and reports each step from the signer's browser straight to Esign Comply. The page is src/routes/signup/index.tsx:

// src/routes/signup/index.tsx
import { $, component$, noSerialize, useSignal, useVisibleTask$, type NoSerialize } from "@builder.io/qwik";
import type { DocumentHead } from "@builder.io/qwik-city";
import { EsignComply, type Ceremony } from "@esigncomply/browser";

// 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 default component$(() => {
  const assent = useSignal<HTMLDivElement>();
  const checkbox = useSignal<HTMLInputElement>();
  const submit = useSignal<HTMLButtonElement>();
  const termsLink = useSignal<HTMLAnchorElement>();
  const privacyLink = useSignal<HTMLAnchorElement>();

  const versions = useSignal<string[]>([]); // the version IDs this session pinned, for the two links
  const ready = useSignal(false); // true once the SDK observes the checkbox
  const canComplete = useSignal(false);
  const message = useSignal("");
  // The ceremony is a live object, made in the browser. noSerialize tells Qwik never to put it in the page state.
  const ceremony = useSignal<NoSerialize<Ceremony>>();

  // 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;
    } catch (error) {
      message.value = error instanceof Error ? error.message : "Something went wrong.";
    }
  });

  const onSubmit = $(async () => {
    if (!ceremony.value) return;
    try {
      const result = await ceremony.value.complete(); // the signing act, from the signer's own click
      // The result came to the browser. Your endpoint confirms the record before anything is granted.
      const confirmed = await fetch("/api/signup/confirm", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({ recordId: result.recordId }),
      });
      message.value = confirmed.ok
        ? `Account created. Record ${result.recordId}`
        : "We could not confirm whether your acceptance was recorded. Please wait while we check.";
    } catch (error) {
      message.value = error instanceof Error ? error.message : "Something went wrong.";
    }
  });

  return (
    // preventdefault:submit, because the handler is loaded on demand and cannot stop the browser's own submit in time.
    <form preventdefault:submit onSubmit$={onSubmit} style={{ font: "16px/1.5 system-ui, sans-serif", maxWidth: "480px", margin: "48px auto", padding: "0 20px" }}>
      <h1>Create account</h1>
      <div ref={assent}>
        {/* The box is in the server HTML, so it stays disabled until the SDK watches it. Only the user changes it. */}
        <label>
          <input ref={checkbox} type="checkbox" disabled={!ready.value} /> I agree to the Terms of Service and Privacy Notice
        </label>
        <p>
          By checking the box and clicking Create account, you agree to the{" "}
          <a ref={termsLink} href={`/legal/terms/?v=${versions.value[0] ?? ""}`} style={LINK}>Terms of Service</a> and acknowledge the{" "}
          <a ref={privacyLink} href={`/legal/privacy/?v=${versions.value[1] ?? ""}`} style={LINK}>Privacy Notice</a>.
        </p>
        <button ref={submit} type="submit" disabled={!canComplete.value}>
          Create account
        </button>
      </div>
      <p role="alert">{message.value}</p>
    </form>
  );
});

export const head: DocumentHead = { title: "Create account" };

Each link opens a document page on your own origin. A routeLoader$ reads the registered version with the secret key, and the component renders that HTML, unmodified:

// src/routes/legal/[slug]/index.tsx
import { component$ } from "@builder.io/qwik";
import { routeLoader$, type DocumentHead } from "@builder.io/qwik-city";
import { documentId, esc } from "~/lib/esigncomply";

// /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 };
});

export default component$(() => {
  const found = useLegalDocument();
  // The registered version, unmodified.
  return found.value ? (
    <article data-esc-document={found.value.versionId} dangerouslySetInnerHTML={found.value.html} />
  ) : (
    <p>This document does not exist.</p>
  );
});

export const head: DocumentHead = { title: "Legal" };

Start the app and open http://localhost:5173/signup/:

npm run dev

The button stays disabled until the box is ticked. Tick it, click Create account, and the page shows:

Account created. Record rec_R6JVhvSy02FZrVtwqoKc

Qwik does not hydrate, and that shapes this page. Six details matter, and each one was seen in the test run.

The ceremony starts in a visible task. No component code runs in the browser until something asks for it, and useVisibleTask$ asks. Qwik's documentation says it runs in the browser only, when its component becomes visible, and at once with the document-ready strategy. One page load sent one POST /api/ceremony, under vite dev and on the built server. The starter's lint rule warns about every visible task, because it runs code eagerly. Here that is the point, so the comment above each task turns the warning off.

The checkbox is disabled until the SDK observes it. The form arrives as HTML and works before any script has run. On the built server the box became usable 0.9 to 2 seconds after it was first visible, in three page loads. In a test without disabled and with the session request held back, a box ticked in that time stayed ticked, and the SDK reported a finding for CR-01 at Block level. The box has no checked attribute: only the user changes it.

The ceremony lives in a signal, wrapped in noSerialize. Every $ closure is a file of its own and gets its own copies of the constants around it. With the ceremony in a plain let variable, the task stopped with TypeError: Assignment to constant variable, the click handler saw undefined, and the starter's lint rule qwik/valid-lexical-scope reported an error.

The links are presented from a second task. It tracks the ceremony signal, so it runs after Qwik has written the two addresses into the page: the SDK's document.presented events carried the addresses with their version IDs and the hash of each document page.

The form carries preventdefault:submit. In a test with event.preventDefault() inside onSubmit$ and no attribute, the handler ran, and the browser still submitted the form and loaded the page again.

The document page keeps the key inside the routeLoader$. In the built files for the browser, a search for getContent, for the key's name and for the signer's email found nothing. What the loader returns is public: the built server answered /legal/terms/q-data.json with it.

Step 6. Confirm the record on the server

The result of ceremony.complete() was delivered to the browser, so your server does not trust it. A second endpoint reads the record with the secret key and grants access only when four things hold: the status is recorded, timestamped or anchored; livemode is what this deployment expects; the signer is the one this server created the session for; and the document versions are exactly the ones it pinned. This step is never optional.

// src/routes/api/signup/confirm/index.ts
import type { RequestHandler } from "@builder.io/qwik-city";
import { SEALED, esc, live, pinned, signer } from "~/lib/esigncomply";

// Step 6: confirm the record with the secret key before the account exists.
export const onPost: RequestHandler = async ({ env, request, json }) => {
  const body = await request.json().catch(() => ({})); // an empty or malformed body is refused below
  const { data: record, error } = await esc(env).records.get(String(body?.recordId));

  const expected = [...(pinned.get(signer.external_id) ?? [])].sort();
  const confirmed =
    !error &&
    SEALED.includes(record.status) &&
    record.livemode === live(env) &&
    record.signer.external_id === signer.external_id &&
    JSON.stringify(record.documents.map((d) => d.version_id).sort()) === JSON.stringify(expected);

  console.log(confirmed ? `confirmed ${record.id} (${record.status})` : "refused");
  if (!confirmed) {
    json(409, { confirmed: false });
    return;
  }
  // Only now create the account, and store record.id and record.receipt with it.
  json(200, { confirmed: true, recordId: record.id });
};

The server prints one line for each confirmation:

confirmed rec_R6JVhvSy02FZrVtwqoKc (recorded)

A record ID that was made up is refused with status 409:

curl -s -X POST http://localhost:5173/api/signup/confirm \
  -H "Content-Type: application/json" -d '{"recordId":"rec_made_up"}'
{"confirmed":false}

That is the answer under vite dev. The built server answered the same request 403 before the endpoint ran, with CSRF check failed. Cross-site POST requests are forbidden., because the request has no Origin header. With -H "Origin: http://localhost:3000" added, the built server on port 3000 answers 409 from the endpoint.

See Server confirmation for the webhook that backs this endpoint up when the browser closes early. A webhook is a POST with no Origin header, so read the note on the origin check in step 8 before you add one.

Step 7. Check the result

Open the dashboard and choose Records. The test record is there with what was observed, what was asserted, and its evidence report, watermarked TEST.

Then run the conformance check against the page. It opens the page in headless Chromium at three window sizes, signs as a visitor would, and tries four things that must be refused. One of them posts a made-up record ID to your confirm route.

npm install --save-dev playwright
npx playwright install chromium
npx esigncomply check --url http://localhost:5173/signup/ --callback http://localhost:5173/api/signup/confirm

The report for this page's code, shortened:

Violations that must be refused
  REFUSED   Submit with the checkbox untouched      No record was made.
  REFUSED   Completion from another origin          The API answered 403 domain_mismatch.
  REFUSED   Programmatic click                      No record was made.
  REFUSED   Forged success posted to your callback  http://localhost:5173/api/signup/confirm answered 409.

Ceremonies
  390x844    record rec_jxPGd00H4TD7CxTBgg1i  session ses_a4p2jKPf4boHfU0MNv1w, 5 events
  768x1024   record rec_JypJFC5tnSsam2sannLn  session ses_99fHmo4jnHdLJMki7P8a, 5 events
  1440x900   record rec_frj9rLpkAxi0N0AyHVhe  session ses_0mR51Y6KDEZ8S24crJRy, 5 events

Summary: 0 block, 0 warn, 27 pass.

This run was made under vite dev, and the dev server logged a confirmed line for each of the three records. On the built server, one ceremony was signed and confirmed: the record shown in step 5. A browser that closes while its confirm request is on the way is another matter. In a test, a confirm request cut off by hand before its body had arrived made the endpoint run with an empty body, and it logged refused. That is the case the webhook of step 6 is for. The checker's forged post has no Origin header, so the built server answers it 403 from the origin check, as in step 6.

Fix every finding marked block and read every finding marked warn. Each one names the rule the screen missed, the measurement and the fix. In test mode a finding never stops a record from being sealed, so read the report. The rules are on Conformance rules, and every flag of the command is on the CLI page.

Step 8. Go live

Going live takes three steps on the Esign Comply side. There is no plan to choose and no checkout: the Free plan records 10 live signatures a month.

  1. Register your production domain and verify it. See Register a domain.
  2. Add your organization's legal name, country and address under Go live in the dashboard.
  3. Create a live key. It is shown once and starts with esc_live_.

Test and live share nothing, so create the documents and the profile again with the live key, or copy them to live from the dashboard, and use the live IDs in production.

Then switch the app over:

  • Set the live key as ESIGNCOMPLY_API_KEY and set ESIGNCOMPLY_LIVE=true in production only. From then on the confirm endpoint refuses every test record there.
  • Give the build a server. The starter has none until you add an adapter. For a Node.js server: npm run qwik add express, then npm run build and npm run serve, which runs node server/entry.express on the port in PORT, or 3000.
  • Give the process its variables. The entry file the adapter writes imports dotenv/config: started in the project folder, the built server read .env and sealed a record. Started in a folder with no .env, or with the key only in .env.local, the session endpoint answered 502 with missing_api_key. On a host, set the variables in its environment.
  • Set ORIGIN to the public address of the site when a proxy sits in front of the server. Qwik City checks the Origin header of every POST against it. With ORIGIN=https://example.com and a page on http://localhost:3000, the session endpoint answered 403.
  • Decide what to do about the webhook. With the origin check on, a POST with no Origin header never reaches an endpoint. Qwik's documentation names one switch, checkOrigin: false in the createQwikCity options of src/entry.express.tsx, and it turns the check off for every route.
  • Replace the pinned Map with a table in your database, and store record.id and record.receipt beside the user.

In live mode context.url must be inside your registered domain, and browser calls are accepted only from it. By default a live signature with a finding at Block level is recorded and you are told at once which rule failed. Turn on blocking, on the dashboard's Conformance page, and it is refused before it is sealed. Run the check from step 7 until no finding is at Block level before you switch keys.

Troubleshooting

  • 403 with CSRF check failed on the built server. Qwik City compares the Origin header of every POST with the server's origin, and vite dev does not. Set ORIGIN to the address visitors use. A curl request needs an Origin header to get past the check.
  • missing_api_key from /api/ceremony. The server process has no ESIGNCOMPLY_API_KEY, so the SDK found no key and the endpoint answers 502. The built Express server reads .env from the folder it is started in, and nothing else. See missing_api_key.
  • domain_mismatch when the page loads. The page was opened from a host that is not on the test allowlist, for example your machine's LAN address from vite --host. Test keys work on localhost and 127.0.0.1 at any port. Add other hosts under Domains in the dashboard. See domain_mismatch.
  • 429 when the confirm endpoint reads the record. The endpoint needs no retry loop: the esigncomply package waits for the time in Retry-After and tries again, up to twice. In the test, four confirmations sent at once for one record all answered 200 on the built server, two of them a second later than the others. Four reads sent at once through the package showed why: two got 429 with Retry-After: 1 and passed on the next attempt. See rate_limit_exceeded and Retries and timeouts.

Questions about the Qwik quickstart

Why is the session not created in a routeLoader$?

Because a loader runs for visitors who never open the page. In a test on the built server, a page that only held a Link to another route requested that route's q-data.json as soon as the link was visible, and the loader ran on the server. Under vite dev the same request went out when the link was hovered.

Why does the page use two visible tasks?

So the links carry their version IDs before the SDK reads them. The first task attaches the ceremony and sets the signals. The second tracks the ceremony signal, and Qwik runs it after it has written the new addresses into the page. The document events then carried both addresses in full.

Why are the endpoints not server$ functions?

Because they are called by address. The page posts to them, and the conformance check posts a made-up record ID to the confirm endpoint. An endpoint is an index.ts file with onPost, at a path you choose. The key is read the same way in both: from env on the request event.

What does the lint warning about useVisibleTask$ mean here?

It means the task runs code in the browser at once, which Qwik avoids by default. Qwik's documentation calls a visible task a last resort for that reason. This page needs exactly that: the SDK has to watch the form before the visitor uses it. The comment above each task turns the warning off.

Does the Qwik quickstart need a domain or a card?

No. Test mode works on localhost with a test key, no card and no domain. You register and verify a domain only when you go live, and the Free plan then records 10 live signatures a month.

Next steps

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.

Last updated · API version 2026-11-21