SigningEmbed component from @sajn/embed-react. The component wraps createSigningEmbed from @sajn/embed-js.
Before you begin
- Turn on embedding for your organization and add your domain to the embed domains. For more information, see Add your embed domains.
- Create and send the document, and note the party’s
id. For the steps, see Embed the signing page. - React 18 or 19.
Install the package
Create a session on your server
Your React code never calls the sajn API. Add a server endpoint that creates an embed session and returns itsclientSecret. In the Next.js App Router, use a route handler:
Show the signing page
RenderSigningEmbed with a fetchClientSecret function. The component is a client component, marked with "use client":
div that holds the frame. className and style apply to that div, so give it a height there.
Props
The callback props are
onReady, onSigned, onRejected, onFieldsSubmitted, onVerified, onStateChange, onResize, onSessionExpired, and onError. For when each one runs and its data, see Events.
Show a document read-only
Create the session withtype: "viewing" and render ViewingEmbed. It takes the same props as SigningEmbed. The frame shows the document with no sign section.
Update the frame
The component readsfetchClientSecret and the callbacks from the latest render, so inline functions are fine and never reload the frame.
- A change to
appearanceorlocaleupdates the open frame without reloading it. - A change to
host,title, orfallbackHeightcreates a new frame and a new session.
In development, React Strict Mode mounts the component twice, so your endpoint gets two requests and creates two sessions. The first session expires unused. Production builds mount once.
TypeScript types
The package exports its types:Troubleshooting
onErrorgetsbootstrap_timeout, and the frame is blank: the browser most likely refused the frame. Check the session’soriginsagainst the page’s exact origin, and your page’s ownframe-srcpolicy. In Next.js, aContent-Security-Policyset innext.configor middleware must allowhttps://app.sajn.seinframe-src. For every cause, see Fix a blank frame.onErrorgetsclient_secret_failed:fetchClientSecretthrew an error, or returned something other than theclientSecretstring.- The frame is 600px high and doesn’t fill the container: the container has no height. Set one with
classNameorstyle.
Next steps
Embedded signing
See the session request, the appearance, the events, and the error codes.
Embed signing in your app
Run the whole flow from server to frame.

