Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

React package for FormBold which simplifies the integration of FormBold with React/Next.js projects.

License

NotificationsYou must be signed in to change notification settings

FormBold/formbold-react

Repository files navigation

React package forFormBold which simplifies the integration of FormBold with React/Next.js projects.

FormBold is a multipurpose form API and serverless backend solution compatible with all hosting, SSG, and frameworks. It allows you to receive form submissions directly in your email, slack, telegram, notion, and more. It's ready for use with any Static, Jamstack, and SSG sites, such as HTML, React, Next.js, Gatsby, Vue, Nuxt, Hugo, and Jekyll.

It offers a wide range of form fields, advanced features like conditional logic, and seamless integration with other tools.

Installation

npm install formbold-react

or

yarn add formbold-react

Usages

To use it you have to import it in your Form component. Then call it with the form_id.

And at the end, attach the handleSubmit function to the onSubmit event.

import{useForm}from"formbold-react";functionForm(){const[state,handleSubmit]=useForm("form_id");if(state.succeeded){return<div>Formsubmittedsuccessfully</div>;}return(<><h1>HomePage</h1><formonSubmit={handleSubmit}><labelhtmlFor="email">EmailAddress</label><inputid="email"type="email"name="email"required/><textareaid="message"name="message"required/><buttontype="submit">{state.submitting ?"Submitting..." :"Submit"}</button><div>{state.error&&state.error.message}</div></form></>);}exportdefaultForm;

Required fields

To make certain fields mandatory in your form, you can use therequiredFields option when using theuseForm hook. In the example below, theemail field is set as a required field:

const[state,handleSubmit]=useForm("form_id",{requiredFields:["email"]});

This ensures that the form cannot be submitted unless theemail field is filled out by the user.

Custom error messages

You can customize the error messages displayed when certain fields are not filled out in your form. By using theerrorMessages option in theuseForm hook, you can provide custom error messages for different scenarios.

Here's an example of how you can set custom error messages for thename andemail fields:

const[state,handleSubmit]=useForm("form_id",{requiredFields:["name","email"],errorMessages:{empty:"Please fill the form!",required:fields=>`Please fill the required fields:${fields.join(", ")}`,}});

Feel free to customize the error messages according to your specific requirements.

Useful Links and Information

For more information visit thedocumentation.

About

React package for FormBold which simplifies the integration of FormBold with React/Next.js projects.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors5


[8]ページ先頭

©2009-2025 Movatter.jp