simple-stack-form

0.1.12 • Public • Published

Simple form 🧘‍♂️

The simple way to handle forms in your Astro project

---
import { z } from "zod";
import { createForm } from "simple:form";

const checkout = createForm({
  quantity: z.number(),
  email: z.string().email(),
  allowAlerts: z.boolean(),
});

const result = await Astro.locals.form.getData(checkout);

if (result?.data) {
  await myDb.insert(result.data);
  // proceed to checkout
}
---

<form method="POST">
  <label for="quantity">Quantity</label>
  <input id="quantity" {...checkout.inputProps.quantity} />

  <label for="email">Email</label>
  <input id="email" {...checkout.inputProps.email} />

  <label for="allowAlerts">Allow alerts</label>
  <input id="allowAlerts" {...checkout.inputProps.allowAlerts} />
</form>

📚 Visit the docs for more information and usage examples.

Package Sidebar

Install

npm i simple-stack-form

Weekly Downloads

869

Version

0.1.12

License

MIT

Unpacked Size

143 kB

Total Files

41

Last publish

Collaborators

  • bholmesdev