Embed document signing into React Native App

1

Document signing form for specified email

Import the WebView component in your file and create a functional component (SignForm, in this case). Inside the component, use the WebView with the HTML source that contains your DocuSeal form. Customize the HTML as needed, including the form's URL and data attributes.

  • data-src: This attribute specifies the URL of the DocuSeal form that you want to embed. Each template form on DocuSeal has a unique URL with slug key. "Slug" key can be obtained via the /templates API or copied from the template page in the web UI.
  • data-email: This attribute is used to initialize the form for a specified email address for the signer.

Signing forms initialized via template URL and email work only if the template contains a single signing party. For signing forms with multiple parties all signers should be initiated via the API.

import { WebView } from 'react-native-webview';

export default function SignForm() {
  return (
    <WebView
      source={{ html: `
        <!DOCTYPE html>
        <html>
          <head>
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <script src="https://cdn.docuseal.co/js/form.js"></script>
          </head>
          <body>
            <docuseal-form
              style="height: 100vh"
              data-src="https://docuseal.co/d/LEVGR9rhZYf86M"
              data-email="signer@example.com"
            > Loading...
            </docuseal-form>
          </body>
        </html>
      ` }}
    />
  );
}
2

Document signing form initiated via API

Prerequisites:

Sign Up and Obtain API Key: Visit DocuSeal API Console to obtain your API key.

Template ID: Identify the template ID you want to use for the form.

POST request to https://api.docuseal.co/submissions. Include the obtained API key in the headers along with the content type ('application/json'). Specify the template_id and submitter details:

  • send_email: set to false to disable automated emails form the platform.
  • email: pass email address of each individual party in the document signing process.
  • role: specifies the designated role of each participant (e.g., 'Director', 'Contractor'). Pass role names defined in the template form.

Upon a successful request, the API will respond with a an array of submitters with slug keys to be used in the embed form.

When utilizing the ${slug} within the <docuseal-form> component, ensure that you load "slug" from your back-end API with the actual key obtained from the DocuSeal API response. This "slug" key acts as a reference point to link the embedded form in your Android app to the specific submitter document form created through the DocuSeal platform.

Learn more:

Embed API Reference

REST API Reference

React Native Example Project

import express from 'express';
import axios from 'axios';

const app = express();
const API_KEY = 'YOUR_API_KEY';

app.post('/your_backend/api/init_form', async (req, res) => {
  const submissionData = {
    template_id: 123,
    send_email: false,
    submitters: [
      {
        email: 'john.doe@example.com',
        role: 'Director'
      },
      {
        email: 'roe.moe@example.com',
        role: 'Contractor'
      }
    ]
  };

  const response = await axios.request({
    method: 'POST',
    url: 'https://api.docuseal.co/submissions',
    headers: {
      'X-Auth-Token': API_KEY,
      'content-type': 'application/json'
    },
    data: submissionData
  });

  const slug = response.data[0].slug; // Extracting the slug from the response
  res.json({ slug }); // Sending the slug in the response
});

app.listen(3000, () => {
  console.log('Server is running on port 3000');
});
import { useEffect, useState } from 'react';
import { WebView } from 'react-native-webview';

export default function SignForm() {
  const [slug, setSlug] = useState('');

  useEffect(() => {
    // Fetch data from the API endpoint
    fetch('https://your-backend.com/api/init_form')
      .then(response => response.json())
      .then(data => {
        setSlug(data.slug); // The API response has a 'slug' field
      })
  }, []); // Empty dependency array ensures this runs only once on component mount

  return (
    <WebView
      source={{ html: `
        <!DOCTYPE html>
        <html>
          <head>
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <script src="https://cdn.docuseal.co/js/form.js"></script>
          </head>
          <body>
            <docuseal-form
              style="height: 100vh"
              data-src="https://docuseal.co/s/${slug}"
            > Loading...
            </docuseal-form>
          </body>
        </html>
      ` }}
    />
  );
}