@convoform/react
TypeScript icon, indicating that this package has built-in type declarations

0.2.3 • Public • Published

@convoform/react

This package provides a React hook, useConvoForm, for creating conversational forms using ConvoForm.com . It is headless and allows you to integrate conversational forms into your React applications seamlessly.

Installation

Install the package with npm or yarn:

npm install @convoform/react
# or
yarn add @convoform/react

Usage

Import and use the useConvoForm hook in your React components:

import { useConvoForm } from "@convoform/react";

function MyComponent() {
  const { submitAnswer, currentQuestion, isBusy } = useConvoForm({
    formId: "your-form-id",
  });

  // Use the hook's returned values and functions to build your UI
}

API

useConvoForm accepts the following parameters:

  • formId: The unique identifier for the form generated on convoform.com .
  • onError?: An optional callback to handle errors.

It returns an object containing:

  • submitAnswer: Function to submit answer of current question to the form.
  • currentQuestion: The current question to be displayed.
  • conversationId: The ID of the current conversation.
  • isBusy: Boolean indicating if the form is currently processing.
  • isFormSubmissionFinished: Boolean indicating if the form submission has completed.
  • resetForm: Function to reset the form to its initial state.

Contributing

Contributions are welcome! Please refer to the repository's issues/PRs sections to contribute or report a bug.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Package Sidebar

Install

npm i @convoform/react

Weekly Downloads

2

Version

0.2.3

License

MIT

Unpacked Size

58.1 kB

Total Files

8

Last publish

Collaborators

  • growupanand