Skip to main content
In this guide, you embed the sajn signing page in a web page with the @sajn/embed-js package, through its function API or its Web Component. The @sajn/embed-js package provides two ways to embed the signing experience: a function API and a Web Component.

Before you begin

  • Turn on embedding for your organization and add your domain to the allowlist. For more information, see Embedded signing.
  • On your server, create the document and read the party’s token from the signingUrl that GET /api/v1/documents/DOCUMENT_ID/parties/PARTY_ID returns. For the steps, see Embed the signing page. Never call the sajn API from the browser, because the request needs your API key.

Installation

npm

CDN

For projects without a build step, use the UMD bundle:
This exposes the sajn global object with all exports.

Use the function API

The embedSignDocument function creates an iframe and handles all communication with the embedded signing interface.

Import

Or with CDN:

Options

Return value

Example

Use the Web Component

The package also exports a custom element <sajn-sign-document> that auto-registers when imported.

Import

Or with CDN, the component is automatically registered.

Attributes

Events

The Web Component dispatches standard CustomEvents that you can listen to:

Example

Use the CDN bundle

Complete HTML page using the UMD bundle:

TypeScript types

The package exports all types for TypeScript users:

View a signed document

The package also includes embedViewDocument for displaying signed documents in read-only mode.

Use the function API

Or with CDN:

Options

Example

Use the Web Component

The package also exports a custom element <sajn-view-document>:

Next steps

Embedded signing

See the shared options, events, and security model.

Embed signing in your app

Run the whole flow from server to iframe.