Skip to content
Source
Sign inSign up
TanStack/form
Open History to see the last commit

quick-start.md

45 lines1.1 KB

1---
2id: quick-start
3title: Quick Start
4---
5​
6The bare minimum to get started with TanStack Form is to create a form and add a field. Keep in mind that this example does not include any validation or error handling... yet.
7​
8```vue
9<!-- App.vue -->
10<script setup>
11import { useForm } from '@tanstack/vue-form'
12​
13const form = useForm({
14 defaultValues: {
15 fullName: '',
16 },
17 onSubmit: async ({ value }) => {
18 // Do something with form data
19 console.log(value)
20 },
21})
22</script>
23​
24<template>
25 <div>
26 <form @submit.prevent.stop="form.handleSubmit">
27 <div>
28 <form.Field name="fullName">
29 <template v-slot="{ field }">
30 <input
31 :name="field.name"
32 :value="field.state.value"
33 @blur="field.handleBlur"
34 @input="(e) => field.handleChange((e.target as HTMLInputElement).value)"
35 />
36 </template>
37 </form.Field>
38 </div>
39 <button type="submit">Submit</button>
40 </form>
41 </div>
42</template>
43```
44​
45From here, you'll be ready to explore all of the other features of TanStack Form!