React
Embed Documenso signing in your React application using the official SDK.
Installation
npm install @documenso/embed-reactDirect Template
import { EmbedDirectTemplate } from '@documenso/embed-react';
const SigningPage = () => {
return (
<EmbedDirectTemplate
token="your-template-token"
name="John Doe"
email="john@example.com"
lockEmail={true}
externalId="order-12345"
onDocumentReady={() => console.log('Ready')}
onDocumentCompleted={(data) => {
console.log('Signed:', data.documentId);
}}
onDocumentError={() => console.error('Error')}
/>
);
};Signing Token
import { EmbedSignDocument } from '@documenso/embed-react';
const SigningPage = ({ token }: { token: string }) => {
return (
<EmbedSignDocument
token={token}
onDocumentCompleted={(data) => {
console.log('Signed:', data.documentId);
}}
/>
);
};Remembering a signer's signature (Platform Plan)
Pass an opaque clientUserId to prefill and persist the signer's signature across your embeds. Never use an email
address or other personal information here, it appears in request logs. See
Persisting Signatures.
<EmbedSignDocument token={token} clientUserId={user.id} />Styling (Platform Plan)
import { EmbedDirectTemplate } from '@documenso/embed-react';
const StyledEmbed = () => {
return (
<EmbedDirectTemplate
token="your-token"
css={`
.documenso-embed {
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
`}
cssVars={{
primary: '#0000FF',
background: '#F5F5F5',
radius: '8px',
}}
darkModeDisabled={true}
/>
);
};See CSS Variables for all available variables.
Complete Example
import { useState } from 'react';
import { EmbedDirectTemplate } from '@documenso/embed-react';
type Status = 'loading' | 'ready' | 'completed' | 'error';
const DocumentSigning = ({ token }: { token: string }) => {
const [status, setStatus] = useState<Status>('loading');
if (status === 'completed') {
return <p>Thank you for signing the document.</p>;
}
if (status === 'error') {
return <p>An error occurred. Please try again.</p>;
}
return (
<div style={{ position: 'relative', height: '100vh' }}>
{status === 'loading' && (
<div style={{ position: 'absolute', inset: 0, display: 'grid', placeItems: 'center' }}>
Loading...
</div>
)}
<EmbedDirectTemplate
token={token}
onDocumentReady={() => setStatus('ready')}
onDocumentCompleted={() => setStatus('completed')}
onDocumentError={() => setStatus('error')}
/>
</div>
);
};See Also
- Embedding Overview - Props reference and concepts
- CSS Variables - Customize appearance
- Editor - Embed document creation