# Add e-signatures and clickwrap to Angular

> Add e-signatures and clickwrap to Angular with esigncomply in the Express server of ng new --ssr and @esigncomply/browser in afterNextRender. Tested code.

Source: https://esigncomply.com/angular

Stack · Angular

To add e-signatures and clickwrap to Angular, install `esigncomply` and `@esigncomply/browser`. The Express server that `ng new --ssr` creates holds the secret key and carries the session route, the confirm route and the document pages. A component attaches the browser SDK in `afterNextRender`. 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/angular)

`npm install esigncomply @esigncomply/browser`

[Angular quickstart](https://esigncomply.com/docs/quickstart/angular)

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

Last updated November 26, 2026

Run in Angular before publishing

**Express route**

src/api.ts (excerpt)

```ts
// Step 4: create the session with the secret key. The browser gets the client token only.
api.post('/api/ceremony', async (req, res) => {
  // The page that runs the ceremony: the origin the browser reports, plus its path.
  const origin = req.get('origin') ?? `${req.protocol}://${req.get('host')}`;

  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}-${randomUUID()}` },
  );
  if (error) return void res.status(502).json({ error: error.code });

  pinned.set(
    signer.external_id,
    session.documents.map((d) => d.version_id),
  );
  res.json({ clientToken: session.client_token, apiUrl: session.api_url, documents: session.documents });
});
```

**Component**

src/app/signup/signup.ts (excerpt)

```ts
constructor() {
  // This class also runs on the server while Angular renders the page.
  // afterNextRender runs in the browser only, once, when the form is in the DOM: one session per page load.
  afterNextRender(() => void this.start());
  inject(DestroyRef).onDestroy(() => this.ceremony?.destroy());
}

private async start() {
  try {
    // Your server 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 ceremony = await EsignComply.attach({ clientToken: session.clientToken, apiUrl: session.apiUrl });
    this.ceremony = ceremony;
    ceremony.on('change', ({ remainingSteps }) => {
      this.canComplete.set(!remainingSteps.some((step) => step !== 'signature.applied'));
    });

    // Point each link at the exact version this session pinned, wait for Angular to update the DOM, then report it.
    this.versions.set(session.documents.map((document: { version_id: string }) => document.version_id));
    await new Promise<void>((resolve) => afterNextRender(() => resolve(), { injector: this.injector }));
    const [terms, privacy] = this.versions();
    await ceremony.presentDocument({ versionId: terms, mode: 'hyperlink', link: this.termsLink().nativeElement });
    await ceremony.presentDocument({ versionId: privacy, mode: 'hyperlink', link: this.privacyLink().nativeElement });
    await ceremony.observeAssent({
      region: this.assent().nativeElement, // notice, links, checkbox, button
      checkbox: this.checkbox().nativeElement,
      submit: this.submit().nativeElement,
    });
    this.ready.set(true);
```

**server.ts**

src/server.ts (excerpt)

```ts
const app = express();
const angularApp = new AngularNodeAppEngine();

// The session route, the confirm route and the document pages. They hold the secret key.
app.use(api);
```

**Confirm route**

src/api.ts (excerpt)

```ts
// Step 6: confirm the record with the secret key before the account exists.
api.post('/api/signup/confirm', json(), async (req, res) => {
  const { data: record, error } = await esc.records.get(String(req.body?.recordId));

  const expected = [...(pinned.get(signer.external_id) ?? [])].sort();
  const confirmed =
    !error &&
    SEALED.includes(record.status) &&
    record.livemode === LIVE &&
    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) return void res.status(409).json({ confirmed: false });
  // Only now create the account, and store record.id and record.receipt with it.
  res.json({ confirmed: true, recordId: record.id });
});
```

Integrate with Angular

## How do you integrate Esign Comply with Angular?

An Angular app runs in the browser, so the secret key needs a server, and with server-side rendering Angular gives you one: `src/server.ts`, an Express app that `ng serve` runs too. The routes go there. The component's class also runs on that server, so it attaches the browser SDK in `afterNextRender`, which runs in the browser only.

Angular is a web framework that empowers developers to build fast, reliable applications that users love.

Source: [Angular documentation, What is Angular?](https://angular.dev/overview), read on November 25, 2026.

[Angular quickstart](https://esigncomply.com/docs/quickstart/angular) · [All stacks](https://esigncomply.com/stacks)

Where each part lives in Angular

- **Express route** · `src/api.ts`
- **Component** · `src/app/signup/signup.ts`
- **server.ts** · `src/server.ts`
- **Confirm route** · `src/api.ts`

Run on 2026-11-26 with Angular 22.3.0 and server-side rendering (@angular/ssr 22.3.0, Express 5.3.0), in the app that ng new --ssr creates, esigncomply 1.0.4 and @esigncomply/browser 1.0.4 on Node.js 24.22.1, under ng serve (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 Angular 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 Angular, 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 Angular

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

Angular facts
- Packages (the only ones that exist): esigncomply (server code, Node.js 20.19 or later) and @esigncomply/browser (the component). There is no Angular package.
- The app needs server-side rendering (ng new --ssr, or ng add @angular/ssr): its Express file src/server.ts is the only place for the secret key. Put the routes in a file that src/server.ts imports, and register them before the Angular handler. Never import that file from anything under src/app.
- The Angular CLI does not read .env. Start ng serve through node --env-file=.env, and add .env to .gitignore: ng new does not list it. Never print the key.
- Never read process.env in a component. The class also runs on the server, and with prerendering it runs at build time: the value ends up in a static HTML file.
- Server SDK calls return { data, error } and do not throw. Check error every time.
- Call fetch and EsignComply.attach inside afterNextRender only. After you set the signal that feeds the two link addresses, wait for the next render before presentDocument.
- The form is in the server HTML before the script loads. Keep the checkbox disabled until observeAssent has resolved.
- The built server answers 400 to a host that is not in security.allowedHosts (angular.json) or in NG_ALLOWED_HOSTS.

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/api.ts, an Express Router that src/server.ts mounts: POST /api/ceremony creates the session with esc.sessions.create and an Idempotency-Key, saves the signer ID and the pinned version IDs in server-owned state, and returns only clientToken, apiUrl and documents.
4. GET /legal/:slug in the same router renders the registered version from esc.documents.versions.getContent inside <article data-esc-document>, unmodified.
5. src/app/signup/signup.ts, a component on the route /signup: in afterNextRender, EsignComply.attach({ clientToken, apiUrl }), presentDocument for each link, observeAssent({ region, checkbox, submit }) with viewChild elements, then ceremony.complete() in the submit handler. The checkbox has no checked attribute and no binding that ticks it.
6. POST /api/signup/confirm in the router 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 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:4200/signup --callback http://localhost:4200/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 Angular?

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

- **The built server answers 400 until your host is allowed**

  `ng new` writes `"allowedHosts": []` into `angular.json`, and Angular's server refuses a `Host` header it does not know. In the test on Angular 22.3.0 the built server answered `/signup` on `localhost` with `400` until `NG_ALLOWED_HOSTS=localhost` was set. `ng serve` answered it without. List your production host before you go live.

  Source: [Angular documentation, Security](https://angular.dev/best-practices/security#preventing-server-side-request-forgery-ssrf), read on November 25, 2026.

- **A component that reads process.env passes the build**

  The app's TypeScript settings include the Node.js types, so `process.env` compiles in a component. In the test, `ng build` prerendered the page and the static HTML held the value from the build machine, and in the browser the same line threw `ReferenceError: process is not defined`. Read the key in the server file only.

- **The server HTML carries a checkbox the SDK does not watch yet**

  Angular sends the form as HTML before the script loads, and hydration keeps the same elements. In a test with the script held back, a box ticked in that HTML stayed ticked, and the browser SDK reported a `CR-01` finding at Block level. The quickstart keeps the box disabled until `observeAssent` has resolved.

  Source: [Angular documentation, Hydration](https://angular.dev/guide/hydration), read on November 25, 2026.

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

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

- Quickstart

  **[Angular quickstart](https://esigncomply.com/docs/quickstart/angular)**

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

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

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

Yes, the two JavaScript packages, and no Angular bindings. The Express server of the app uses `esigncomply`, and a component calls `@esigncomply/browser` directly in `afterNextRender`. The browser SDK is headless, so it attaches to the template you wrote.

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

In `src/server.ts`, the Express server that `ng new --ssr` creates, with `esc.sessions.create`. The quickstart puts the routes in `src/api.ts` and mounts them before the Angular handler. The route returns only the client token, the API URL and the pinned documents.

### Does ng serve run the routes in src/server.ts?

Yes. In the test on Angular 22.3.0, `ng serve` answered `POST /api/ceremony` and the document pages from the Express routes of that file, with no proxy and no second process. The Angular CLI does not read `.env`, so the quickstart starts it through `node --env-file=.env`.

### Why does the component wait for a render before presentDocument?

Because a signal does not change the DOM at once, and the app `ng new` creates has no zone.js. In the test, without the wait the SDK requested the first link as `/legal/terms?v=`, with no version ID. The quickstart awaits `afterNextRender` after it sets the version IDs.

### What happens when a component imports the server file?

The build stops. In the test, `ng build` failed with `Could not resolve "node:crypto"` when a component imported `src/api.ts`, because the browser bundle cannot hold the Node.js modules that `esigncomply` and Express use. The quickstart keeps that file outside `src/app`.

### Other stacks

- [React](https://esigncomply.com/react)
- [Vue](https://esigncomply.com/vue)
- [Next.js](https://esigncomply.com/nextjs)

### Platforms used with Angular

- [Google Cloud Run](https://esigncomply.com/google-cloud-run)
- [Render](https://esigncomply.com/render)
- [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 Angular app. Leave the record to us.

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

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

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