@anvilco/react-signature-modal

中文文档
2.1.4发布于 2025/10/29MITTypeScriptCommonJS零依赖近 30 天下载 4.4万

The AnvilSignatureModal React component for embedded Etch signatures

原始使用文档
文档目录21 节
  1. What is Anvil?
  2. Usage
  3. Upgrading from v1 to v2
  4. Props
  5. id
  6. iframeURL
  7. isOpen
  8. onClose
  9. onEvent
  10. onLoad
  11. modalAppElement
  12. showIconClose
  13. iframeWarningProps
  14. anvilFrameProps
  15. iconCloseProps
  16. Styling
  17. Anvil Etch E-Sign Docs
  18. Links 🔗
  19. Notes
  20. Bugs
  21. Questions or Feedback

AnvilSignatureModal

A lightweight modal component that allows embedding Anvil Etch e-signatures via a modal popup in your app. It will give you information via callbacks through the signing process lifecycle. Compatible with mobile viewports with minimal dependencies.

See the live demo and open-source demo repository for a usage example.

image

What is Anvil?

Anvil provides easy APIs for all things paperwork.

  1. PDF filling API - fill out a PDF template with a web request and structured JSON data.
  2. PDF generation API - send markdown or HTML and Anvil will render it to a PDF.
  3. Etch E-sign with API - customizable, embeddable, e-signature platform with an API to control the signing process end-to-end.
  4. Anvil Workflows (w/ API) - Webforms + PDF + E-sign with a powerful no-code builder. Easily collect structured data, generate PDFs, and request signatures.

Learn more on our Anvil developer page.

Usage

yarn add @anvilco/react-signature-modal
npm install @anvilco/react-signature-modal
import AnvilSignatureModal from '@anvilco/react-signature-modal'
import '@anvilco/react-signature-modal/dist/styles.css'

<AnvilSignatureModal
  iframeURL={iframeURL}
  isOpen={isModalOpen}
  onClose={() => setIsModalOpen(false)}
  onLoad={() => setLoading(false)}
  onEvent={(eventObject) => {
    console.log(eventObject)

    // See https://www.useanvil.com/docs/api/e-signatures/#iframe-event-details
    // for all event details.
    //
    // Example:
    //
    // {
    //   action: 'signerComplete',
    //   signerStatus: 'completed',
    //   signerEid: 'Jc1ZJisPnpF5lHyfyqBW',
    //   nextSignerEid: 'WBqyfyHl5FpnPsiJZ1cJ',
    //   documentGroupStatus: 'partial',
    //   documentGroupEid: 'nEKq2eGim0ijSqKd98nG',
    //   etchPacketEid: 'XzfmVPfGUEyBc1XyylFo',
    // }
  }}
/>

Upgrading from v1 to v2

As of v2.0, the AnvilSignatureModal now uses AnvilEmbedFrame under the hood. The props have changed slightly:

  • signURL -> iframeURL
  • onFinishSigning -> onEvent. Check the eventObject.action === 'signerComplete' to detect a signer has finished signing
  • onError -> onEvent. Check the eventObject.error to determine if there is an error
// v1.x
<AnvilSignatureModal
  // Changed props, see below
  signURL={signURL}
  onFinishSigning={(eventObject) => console.log(eventObject)}
  onError={(eventObject) => console.log(eventObject)}

  // Unchanged!
  isOpen={isModalOpen}
  onClose={() => setIsModalOpen(false)}
  onLoad={() => setLoading(false)}
/>

// v2.x
<AnvilSignatureModal
  // New
  iframeURL={iframeURL}
  onEvent={(eventObject) => {
    console.log(eventObject)
    if (eventObject.action === 'signerComplete') {
      // Signer has finished signing
    } else if (eventObject.error) {
      // There has been an error
    }
  }}

  // Unchanged!
  isOpen={isModalOpen}
  onClose={() => setIsModalOpen(false)}
  onLoad={() => setLoading(false)}
/>

Props

id

string - html id attribute, overriding the id will also remove all default styling for the react-siganture-modal. If you just want to override specific styling elements use the anvilFrameProps below.

iframeURL

string (required) - A URL to the Anvil signature page generated from the generateEtchSignURL GraphQL mutation. The signature frame will be displaying the signing page through this URL.

Example:

iframeURL={`https://app.useanvil.com/etch/8iJDbq8dkEmjrsNw7Dnb/sign?token=dsa...`}

isOpen

boolean - The modal is displayed if isOpen is true.

onClose

function - This function is called when the X button is clicked on the top right corner.

Example:

onClose={() => setIsOpen(false))}

onEvent

function - A callback function with payload as a parameter. It is called when a user has successfully finished signing.

Example:

onEvent={(eventObject) => console.log(eventObject)}

/*
{
  action: "signerComplete",
  signerEid: "kJzR6mcIWKoZs6KOxV4w",
  signerStatus: "completed",
  nextSignerEid: "HRLhx4khticpfxsUFSpj",
  documentGroupEid: "9fQnvfy51p7oKrEYajMh",
  documentGroupStatus: "partial",
  etchPacketEid: "J1phQTO6WQH6gZcMJAG5", // If from an EtchPacket
  weldDataEid: "J1phQTO6WQH6gZcMJAG5", // If from a workflow
}
*/

See our e-sign docs for full details on all iframe events.

onEvent is also called when a user experiences an error while attempting to sign. See the docs for details on how to recover from errors.

Example error payload:

{
  action: "signerError",
  errorType: "tokenExpired", tokenExpired || tokenInvalid || notFound
  error: "Token Expired",
  message: "Error specific message",
  signerEid: "kJzR6mcIWKoZs6KOxV4w",

  // depending on the errorType, you may or may not receive the following
  signerStatus: "sent",
  nextSignerEid: "HRLhx4khticpfxsUFSpj",
  documentGroupEid: "9fQnvfy51p7oKrEYajMh",
  documentGroupStatus: "sent",
  etchPacketEid: "J1phQTO6WQH6gZcMJAG5", // If from an EtchPacket
  weldDataEid: "J1phQTO6WQH6gZcMJAG5", // If from a workflow
}

onLoad

function - This function is called when the signing page has finished loading.

Example:

onLoad={() => setLoading(false)}

modalAppElement

string - Pass in a query selector identifying the root of your app. Used to hide other page content while the modal is open for screenreaders and other accessibility purposes.

Default: #root

showIconClose

boolean -Show the close icon on the top right of the modal if true.

iframeWarningProps

object - Pass in custom props into the paragraph tag displayed if the user's browser does not support iframes.

Example:

iframeWarningProps={{ className: 'warning-text' }}

anvilFrameProps

object - Pass in custom props into the iframe tag displayed within the modal.

Example:

anvilFrameProps={{
  style: { background: 'white' },
}}

iconCloseProps

object - Pass in custom props into the svg tag for the delete button displayed within the modal.

Example:

iconCloseProps={{ className: 'red-delete-button' }}

Styling

Customize the component by importing your own CSS stylesheet. Override IDs or classNames by passing them in as props.

Anvil Etch E-Sign Docs

Read the Docs

Notes

  • To enable Iframe embedding: go to your organization's settings in Anvil, and enable "Iframe Embedding" in the API section.
  • React >= v16.0 required.

Bugs

Please file an issue for bugs, missing documentation, or unexpected behavior.

Questions or Feedback

Please email us at [email protected].

版本与发布记录

@anvilco/react-signature-modal 共发布 24 个版本,首次发布于 2020/11/13;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.1.4latest2025/10/291 年前
2.1.32025/10/291 年前
2.1.22025/10/281 年前
2.1.12025/04/221.5 年前
2.1.02024/05/032 年前
2.0.12023/09/213 年前

关于 @anvilco/react-signature-modal 的常见问题

@anvilco/react-signature-modal 是什么?

The AnvilSignatureModal React component for embedded Etch signatures

如何安装 @anvilco/react-signature-modal?

在项目目录运行 npm install @anvilco/react-signature-modal,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=16)、react-dom(>=16)、prop-types(^15.6.0)、react-modal(^3.11.2)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@anvilco/react-signature-modal 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@anvilco/react-signature-modal 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@anvilco/react-signature-modal 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js *。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@anvilco/react-signature-modal 可以商用吗?

@anvilco/react-signature-modal 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@anvilco/react-signature-modal 的下载量有多少?

根据 npm 官方下载统计,@anvilco/react-signature-modal 在 2026/10/06 – 2026/11/04 这 30 天内被下载 44,499 次,日均约 1,483 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@anvilco/react-signature-modal 还在维护吗?

最新版本 2.1.4 发布于 2025/10/29(1 年前);至今共发布 24 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/11/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。