Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

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

Vue composition API functions for Formspark
https://github.com/formspark/vue-use-formspark

form forms jamstack static vue

Last synced: about 9 hours ago
JSON representation

Vue composition API functions for Formspark

Awesome Lists containing this project

README

        



Formspark logo

vue-use-formspark


Vue composition API functions for Formspark.

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

## Installation

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

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

## Usage

```vue



Send

import { ref } from "vue";
import { useFormspark } from "@formspark/vue-use-formspark";
export default {
setup() {
const message = ref("");

const [submit, submitting] = useFormspark({
formId: "your-form-id"
});

const onInput = e => {
message.value = e.target.value;
};

const onSubmit = async e => {
e.preventDefault();
await submit({ message: message.value })
message.value = "";
};

return {
message,
onInput,
onSubmit,
submitting,
};
}
};

```

**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)