Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/formspark/use-formspark

React hooks for Formspark
https://github.com/formspark/use-formspark

form forms formspark hook jamstack react react-hooks static static-site

Last synced: 3 months ago
JSON representation

React hooks for Formspark

Awesome Lists containing this project

README

        



Formspark logo

use-formspark


React hooks for Formspark.


Works with React and React Native.

[![Continuous deployment](https://github.com/formspark/use-formspark/workflows/Continuous%20deployment/badge.svg)](https://github.com/formspark/use-formspark/actions?query=workflow%3A%22Continuous+deployment%22)

## Installation

```bash
# NPM
npm install @formspark/use-formspark

# Yarn
yarn add @formspark/use-formspark
```

## Usage

```tsx
import React, { useState } from "react";
import { useFormspark } from "@formspark/use-formspark";

const ContactForm = () => {
const [submit, submitting] = useFormspark({
formId: "your-form-id"
});
const [message, setMessage] = useState("");
return (
{
e.preventDefault();
await submit({ message })
}}>
setMessage(e.target.value)}
/>
Send

);
};
```

**Note:** do not mistake action url (e.g. `https://submit-form.com/capybara`) and form id (e.g. `capybara`), this package only uses the latter.

## License

[MIT](https://opensource.org/licenses/MIT)