1.0.46 • Published 8 months ago

@docuseal/react v1.0.46

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

DocuSeal React Components

📙 Documentation | 💻 Examples | 🚀 Demo App

This package provides a convenient way to embed DocuSeal into React apps. Sign documents and create document forms directly in your apps.

Docuseal Form

Installation

npm install @docuseal/react

Documentation

For detailed documentation, please click here.

Usage

Signing Form

Copy public DocuSeal form URL from https://docuseal.co and use it in the src component prop:

import React from "react"
import { DocusealForm } from '@docuseal/react'

export function App() {
  return (
    <div className="app">
      <DocusealForm
        src="https://docuseal.co/d/LEVGR9rhZYf86M"
        email="signer@example.com"
      />
    </div>
  );
}

Form Builder

React Client Render

import React, { useEffect, useState } from 'react'
import { DocusealBuilder } from '@docuseal/react'

export function App() {
  const [token, setToken] = useState()

  useEffect(() => {
    fetch('/api/docuseal/builder_token', {
      method: 'POST'
    }).then(async (resp) => {
      const data = await resp.json()

      setToken(data.token)
    })
  }, []);

  return (
    <div className="app">
      {token && <DocusealBuilder token={token} />}
    </div>
  );
}

To protect the template builder from unathorized access a secure token (JWT) should be generated on the back-end:

const express = require('express');
const jwt = require('jsonwebtoken');

const app = express();

app.post('/api/docuseal/builder_token', (req, res) => {
  const token = jwt.sign({
    user_email: 'your-docuseal-user-email@company.com',
    integration_email: 'customer@example.com', // replace with current user email
    name: 'Integration W-9 Test Form',
    document_urls: ['https://www.irs.gov/pub/irs-pdf/fw9.pdf'],
  }, process.env.DOCUSEAL_TOKEN);

  res.json({ token });
});

app.listen(8080, () => {
  console.log(`Server is running`);
});

Obtain secret API token (DOCUSEAL_TOKEN env variable) to sign JWT from https://console.docuseal.co/api.

Find Express.js example project here.

Next.js SSR

import jwt from 'jsonwebtoken';
import { DocusealBuilder } from '@docuseal/react'

export default function Home() {
  const token = jwt.sign( {
    user_email: process.env.DOCUSEAL_USER_EMAIL,
    integration_email: 'test@example.com',
    name: 'Integration W-9 Test Form',
    document_urls: ['https://www.irs.gov/pub/irs-pdf/fw9.pdf'],
  }, process.env.DOCUSEAL_TOKEN);

  return (
    <div>
      <h1>Docuseal Builder</h1>
      <DocusealBuilder token={token} />
    </div>
  );
}

Find Next.js example project here.

License

MIT

1.0.46

8 months ago

1.0.39

12 months ago

1.0.40

11 months ago

1.0.44

9 months ago

1.0.43

11 months ago

1.0.42

11 months ago

1.0.41

11 months ago

1.0.45

9 months ago

1.0.38

1 year ago

1.0.37

1 year ago

1.0.36

1 year ago

1.0.35

1 year ago

1.0.34

1 year ago

1.0.33

1 year ago

1.0.32

1 year ago

1.0.31

1 year ago

1.0.30

1 year ago

1.0.29

1 year ago

1.0.28

1 year ago

1.0.26

1 year ago

1.0.27

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.22

1 year ago

1.0.23

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago