Embedded signing
Headless Signer Flow
The layer below: your app renders every step, and the evidence says so. Checks the document's hash before it allows signing.
- @signnative/ui
- MIT
- Client only · mock server here
- Prototype · ADR 0033 proposed
A prototype for ADR 0033 (proposed), shown against a mock server in your browser. Nothing is sent and nothing is signed.
It never acts by itself: opening, sending a code, signing and declining each follow a press. Sign stays disabled until the person ticked consent for exactly what is on screen. For evidence as strong as the hosted page, use the Signer Flow with secure elements.
The CSS variables this sets
:root {
--signing-accent: #3157e8;
--sig-accent: #3157e8;
--sig-accent-soft: color-mix(in oklab, #3157e8 14%, white);
--sig-radius: 8px;
--radius-control: 8px;
--radius-panel: 12px;
--font-sans: var(--font-inter), ui-sans-serif, system-ui, sans-serif;
}In the signer page kit, set the accent with accentProps(accent) on the element around the surface; it sets data-signing-accent and --signing-accent. The secure elements take the same values as a checked appearance object instead.
Link from the sender
Loading the document…
Mock server: waiting for the person.
import { useMemo } from "react";
import { HeadlessSignerFlow, createMockHeadlessAdapter } from "@signnative/ui";
import "@signnative/ui/styles.css";
export function Example() {
const adapter = useMemo(() => createMockHeadlessAdapter({ verification: "sender_link" }), []);
return (
<HeadlessSignerFlow
adapter={adapter}
headingLevel={3}
renderDocument={(d) => <pre aria-label={d.title}>{new TextDecoder().decode(d.bytes)}</pre>}
onSigned={() => console.log(adapter.signed())}
/>
);
}
Email code
The mock accepts 123456. No email is sent.
Loading the document…
Mock server: waiting for the person.
import { useMemo } from "react";
import { HeadlessSignerFlow, createMockHeadlessAdapter } from "@signnative/ui";
import "@signnative/ui/styles.css";
export function Example() {
const adapter = useMemo(() => createMockHeadlessAdapter({ verification: "email_otp" }), []);
return <HeadlessSignerFlow adapter={adapter} headingLevel={3} />;
}
Error: the document does not match
The mock serves other bytes than the hash in the view. The flow refuses to let the person sign.
Loading the document…
Mock server: waiting for the person.
import { useMemo } from "react";
import { HeadlessSignerFlow, createMockHeadlessAdapter } from "@signnative/ui";
import "@signnative/ui/styles.css";
export function Example() {
const adapter = useMemo(() => createMockHeadlessAdapter({ tamperDocument: true }), []);
return <HeadlessSignerFlow adapter={adapter} headingLevel={3} />;
}
Phone width
Loading the document…
Mock server: waiting for the person.
import { useMemo } from "react";
import { HeadlessSignerFlow, createMockHeadlessAdapter } from "@signnative/ui";
import "@signnative/ui/styles.css";
export function Example() {
const adapter = useMemo(() => createMockHeadlessAdapter({ verification: "email_otp" }), []);
return <HeadlessSignerFlow adapter={adapter} />;
}
Installation
npx shadcn@latest add …
Not published yet
API
className and children are left out: every component that takes them passes them on.
HeadlessSignerFlow
| Name | Type | Default | Description |
|---|---|---|---|
| adapter | HeadlessSignerAdapter | Your connection to a signing server. For another link, also change the key. | |
| renderDocument | (doc) => ReactNode | Shows the document. Called only with bytes whose SHA-256 matched the view. | |
| onSigned | () => void | Called after the server accepted the signature. | |
| onDeclined | () => void | Called after the person declined. | |
| labels | Partial<HeadlessSignerFlowLabels> | English | Every text, for translation. |
| headingLevel | 2 | 3 | 2 | Level of the envelope title. |
createMockHeadlessAdapter
| Name | Type | Default | Description |
|---|---|---|---|
| verification | "sender_link" | "email_otp" | "sender_link" | How the signer opens the document. |
| code | string | "123456" | email_otp: the code the mock accepts. |
| tamperDocument | boolean | false | Serve other bytes than the view's hash, as a broken server would. |
| title | string | "Synthetic NDA (test)" | Envelope title. |
| sender | string | "Example Workspace" | Who sent it. |
| signerName | string | "Ada Example" | The signer's name. |
| signerEmail | string | "ada@example.com" | The signer's address, shown masked. |
| fields | SignerField[] | Fields. Default: a required text field and a signature. |
Accessibility
- Errors are announced (role=alert) and the flow sets aria-busy while it works.
- Signature entry is Signature Capture, so the person can type instead of draw.