Skip to content
Platform · Turso

E-signatures and clickwrap with Turso

To add e-signatures and clickwrap with Turso, run the esigncomply package in a Node.js server and keep the pinned versions and the receipt in a Turso database through @libsql/client. The database URL and its auth token are two secrets of your host, beside the API key. Esign Comply seals each acceptance 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.

$npm install esigncomply @libsql/client
Turso quickstart

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

Last updated

Run locally for Turso before publishing
server.js (excerpt)
// 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 });
  // In the Turso database, not in memory: the confirmation can reach another instance of this server.
  await savePinned(signer.external_id, session.documents.map((d) => d.version_id).sort());
  return json(res, 200, { clientToken: session.client_token, apiUrl: session.api_url, documents: session.documents });
}
Integrate with Turso

How do you integrate Esign Comply with Turso?

With Turso the server half runs on your own host and reaches the database over HTTP with @libsql/client. Two variables name the database, TURSO_DATABASE_URL and TURSO_AUTH_TOKEN. SQLite has no JSON type, so the pinned version IDs are stored as text, and every instance of the server reads the remote database, not a local copy.

Turso Cloud is a fully managed database platform, designed to scale from prototype to production. It hosts two database engines, both fully compatible with SQLite.

Source: Turso documentation, Turso Cloud, read on .
Where each part lives on Turso
  • Session routeserver.js
  • Turso storestore.js
  • Confirmserver.js
  • Tablemigrate.js

Run on 2026-11-26 with Node.js 24.22.1, esigncomply 1.0.4, @libsql/client 0.18.0, the browser SDK script build and the conformance check from esigncomply 1.0.4, as two instances of the server on one database served by turso dev (Turso CLI 1.0.34 starting libsql-server 0.24.32, SQLite 3.45.1), with no Turso account and no login, against the API in test mode. A second turso dev started with --auth-jwt-key-file checked the auth token, and embedded replicas, batches and interactive transactions were tried against the same local server. The Turso Cloud settings are from Turso's documentation as of that date, and the turso db commands in step 8 were not run. No Turso Cloud database has been used yet.

Three steps

How does Esign Comply fit with Turso?

Each step uses a feature Turso already has. The secret key stays on the server side of Turso in all three.

  1. 01
    Three secrets on your hostESIGNCOMPLY_API_KEY is read by the SDK. TURSO_DATABASE_URL and TURSO_AUTH_TOKEN go to createClient. Turso's documentation says SDKs require an auth token unless you work locally, and the local server of turso dev asked for none in the test. Source: Turso documentation, Authentication, read on .
  2. 02
    Your server creates the sessionPOST /api/ceremony calls esc.sessions.create and returns the client token. The same server serves the signup page, and the browser SDK records the ceremony from the signer's device. Turso is not in that path: it holds what the server has to remember.
  3. 03
    A Turso table keeps the receiptThe session route stores the pinned versions as JSON text in a table of the database. The confirm route reads the record with the secret key, compares it with the row, and writes the record ID, the receipt and the time into it. @libsql/client is Turso's package for a remote libSQL database. Source: Turso documentation, TypeScript reference, read on .
Turso setup

Where do the key, the preview hosts and the webhook go on Turso?

Four settings carry an Esign Comply integration on Turso. What is said here about Turso was read from its own documentation, and the quickstart has each command.

The URL and the token

turso db show NAME --url prints the URL and turso db tokens create NAME creates a token. Turso's documentation says that token grants full access and never expires unless you pass --expiration. On the local server started with --auth-jwt-key-file, a missing or expired token failed with HTTP status 401 and a read-only token with 403 on the first write.

Source: Turso documentation, db tokens create, read on .

Local development

turso dev starts a local libSQL server and prints its URL, http://127.0.0.1:8080. In the test, Turso CLI 1.0.34 ran it with no login. It starts sqld, which the CLI does not include: without it on the PATH the command printed Could not start libsql-server. Pass --db-file, or the data is lost when the server stops.

Source: Turso documentation, Local Development, read on .

Preview databases and test mode

Turso's documentation describes branching: turso db create NAME --from-db PRODUCTION creates a separate database, and it suggests one for each pull request. A branch needs a token of its own or a group token, and you delete it yourself. Give each preview its branch and the test key, and list the preview's exact host under Domains in the Esign Comply dashboard as a test origin.

Source: Turso documentation, Branching, read on .

The registered domain and the webhook

Turso serves the database, not your pages: register the domain your host serves the signup page on, and verify it with one DNS record. For the record.completed webhook, add a route to the server and register its production URL under Webhooks in the Esign Comply dashboard.

Read on : Turso documentation, Turso Cloud, Turso documentation, Turso SDKs, Turso documentation, TypeScript reference, Turso documentation, Authentication, Turso documentation, Authorization, Turso documentation, Local Development, Turso documentation, Embedded Replicas, Turso documentation, Branching, Turso documentation, SQL over HTTP reference, Turso documentation, db create, Turso documentation, db show, Turso documentation, db tokens create, libSQL repository, Build and run sqld.

Copy-paste prompt

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

Turso facts
- Packages (the only ones that exist): esigncomply (server, Node.js 20.19 or later, an ES module) and @esigncomply/browser. Without a bundler, load the browser SDK from https://esigncomply.com/sdk/v1/esigncomply.js. The database client is Turso's @libsql/client, for a libSQL database on Turso Cloud.
- Three secrets on the host: ESIGNCOMPLY_API_KEY, TURSO_DATABASE_URL and TURSO_AUTH_TOKEN. Never commit them, never print them. The local server of turso dev asks for no token.
- createClient({ url, authToken }) with the remote URL. No file: URL and no embedded replica for this table when more than one instance of the server runs: another instance reads its own copy.
- SQLite has no JSON type and no timestamp type. JSON.stringify the version IDs and JSON.parse them on read. Store the time as an ISO string. Never pass an array or a Date as an argument: the client stores "a,b" and a number of milliseconds, with no error.
- Write with one statement or with client.batch(). Never hold client.transaction() open across the call to Esign Comply: an interactive transaction times out after 5 seconds and blocks other writers until then.
- Give each preview a database of its own (turso db create NAME --from-db PRODUCTION) with a token of its own, and the test key.
- Expect live records only where ESIGNCOMPLY_LIVE is "true": production.
- The page is on screen before the script has a session: render the checkbox disabled and enable it when observeAssent has resolved.

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 the Turso database, 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. Browser: EsignComply.attach({ clientToken, apiUrl }), presentDocument for each link, observeAssent({ region, checkbox, submit }), then complete() from the user's real click.
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 row in the database. Only then create the account, and store the record ID and the receipt in the same row.

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 on Turso?

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

  • 01

    An array argument is stored as a,b and a Date as milliseconds

    In the test with @libsql/client 0.18.0, an array passed as an argument was stored as the text dv_1,dv_2, an object as [object Object] and a Date as 1795665600000.0, all with no error. SQLite has no JSON type and no timestamp type. The quickstart stores JSON.stringify of the version IDs and an ISO string, and parses the text when it reads the row.

  • 02

    An embedded replica on another instance does not see the session

    Turso's documentation says an embedded replica serves reads from a local file, and that other replicas see new data when they call sync() or at the next sync period. In the test with two replicas of one database, the first wrote a row and the second read none until it synced. The confirm route can run on another instance, so the quickstart reads the remote database.

    Source: Turso documentation, Embedded Replicas, read on .
  • 03

    A transaction left open times out after 5 seconds

    Turso's documentation says an interactive transaction locks the database for writing, with a 5-second timeout. In the test, a write transaction held for 7 seconds failed at commit with TRANSACTION_TIMEOUT, its insert was gone, and a write from a second client waited 5.1 seconds. Never keep one open across the call to Esign Comply. The quickstart writes with one statement, and creates the table with batch().

    Source: Turso documentation, TypeScript reference, read on .
Verifiable

What does Esign Comply record for a signature on Turso?

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

How does test mode work on preview URLs with Turso?

Give each preview a database of its own and the test key. Turso's documentation describes branching, turso db create with --from-db, for one database per pull request, each with its own token. The preview runs on your host's URL, which a test key refuses until you list that exact host under Domains as a test origin.

Where should the receipt be stored with Turso?

In a table of the Turso database, beside the signer ID and the record ID. The confirm route writes the receipt and the time once the record is confirmed. Esign Comply keeps the sealed record itself, and the receipt is the signed token that names it.

Which Turso package does a Node.js server use for this?

@libsql/client, Turso's client for a remote libSQL database, which is what turso db create makes by default. Turso's documentation names @tursodatabase/serverless for a remote database of the newer Turso engine, which it marks as an early preview on Turso Cloud. The quickstart was run with @libsql/client 0.18.0.

Can the server use an embedded replica or a local file?

Not for this table when more than one instance runs. In the test, a second embedded replica read no row until it called sync(), and two file: URLs shared nothing. The confirm route has to see the versions the session route pinned, wherever each request lands.

Was this code run against Turso Cloud?

Not yet. It ran against the local libSQL server that turso dev starts, with and without an auth token, as two instances of the server on one database. Creating a database, its URL and tokens, branches and the hosted database's behaviour are proven only on Turso Cloud.

Keep the receipt in your Turso database. Leave the record to us.

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

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

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