Skip to content

Commit 4cc4f5c

Browse files
committed
chore: add blog post for TanStack Form v1's launch
1 parent 358f9b1 commit 4cc4f5c

File tree

2 files changed

+186
-0
lines changed

2 files changed

+186
-0
lines changed
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
---
2+
title: Announcing TanStack Form v1
3+
published: 03/03/2025
4+
authors:
5+
- Corbin Crutchley
6+
---
7+
8+
We're excited to announce the first stable version of [TanStack Form](/form/v1) is live and ready for usage in production! 🥳
9+
10+
We support five frameworks at launch: React, Vue, Angular, Solid, and Lit, as well as a myriad of features for each specific framework.
11+
12+
# How to install
13+
14+
```shell
15+
$ npm i @tanstack/react-form
16+
# or
17+
$ npm i @tanstack/vue-form
18+
# or
19+
$ npm i @tanstack/angular-form
20+
# or
21+
$ npm i @tanstack/solid-form
22+
# or
23+
$ npm i @tanstack/lit-form
24+
```
25+
26+
# A bit of history
27+
28+
It was nearly two years ago when [I saw Tanner's BlueSky (an invite-only platform at the time) post announcing that he was working on a new project: TanStack Form](https://bsky.app/profile/tannerlinsley.com/post/3ju5z473w5525).
29+
30+
![A back and forth between Tanner and myself on Bluesky about TanStack Form](/blog-assets/announcing-tanstack-form-v1/tanstack_form_bluesky_announce.png)
31+
32+
At the time, I had just launched an alternative form library for React called "[HouseForm](https://web.archive.org/web/20240101000000*/houseform.dev)" and I was immediately enamored by some of the ideas Tanner's library brought to the table.
33+
34+
I was fortunate enough to attend a hackathon that Tanner was also going to soon after and we were able to get some time to work on integrating some APIs from HouseForm into the project.
35+
36+
Since that time, Tanner's handed much of the reigns of Form over to me and a wonderful group of additional maintainers.
37+
38+
So, what have we built in that time?
39+
40+
# Features
41+
42+
One of the advantages of being in the oven for so long is that TanStack Form launches with a flurry of features you can leverage day one.
43+
44+
Let's go over _just a few_ of them using React's adapter as examples.
45+
46+
## Extreme type safety
47+
48+
Like many all of the TanStack projects, Form has revolutionized what it means to be a "type-safe" form library.
49+
50+
```tsx
51+
const form = useForm({
52+
defaultValues: {
53+
name: "",
54+
age: 0
55+
}
56+
});
57+
58+
// TypeScript will correctly tell you that `firstName` is not a valid field
59+
<form.Field name="firstName"/>
60+
61+
// TypeScript will correctly tell you that `name`'s type is a `string`, not a `number`
62+
<form.Field name="name" children={field => <NumberInput value={field.state.value}/>}/>
63+
```
64+
65+
We even support type-checking what errors are returned in `<form.Field>`:
66+
67+
```tsx
68+
<form.Field
69+
name="age"
70+
validators={{onChange: ({value}) => value < 12 ? {tooYoung: true} : undefined}}
71+
children={field => (
72+
<>
73+
<NumberInput value={field.state.value}/>
74+
// TypeScript will correctly tell you that `errorMap.onChange`
75+
// is an object, not a string
76+
<p>{field.state.meta.errorMap.onChange}</p>
77+
</>
78+
)}
79+
/>
80+
```
81+
82+
> Oh, yeah, we support field-based validation as well as form validation. Mix-n-match them!
83+
84+
The best part? [You won't need to pass any typescript generics to get this level of type safety](/form/latest/docs/philosophy#generics-are-grim). Everything is inferred from your runtime usage.
85+
86+
## Schema validation
87+
88+
Thanks to the awesome work by the creators of [Zod](http://zod.dev/), [Valibot](https://valibot.dev), and [ArkType](https://arktype.io/), we support [Standard Schema](https://github.com/standard-schema/standard-schema) out of the box; no other packages needed.
89+
90+
```tsx
91+
const userSchema = z.object({
92+
age: z.number().gte(13, 'You must be 13 to make an account'),
93+
})
94+
95+
function App() {
96+
const form = useForm({
97+
defaultValues: {
98+
age: 0,
99+
},
100+
validators: {
101+
onChange: userSchema,
102+
},
103+
})
104+
return (
105+
<div>
106+
<form.Field
107+
name="age"
108+
children={(field) => {
109+
return <>{/* ... */}</>
110+
}}
111+
/>
112+
</div>
113+
)
114+
}
115+
```
116+
117+
## Async validation
118+
119+
That's not all, though! We also support async functions to validate your code; complete with built-in debouncing and [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)-based cancellation:
120+
121+
```tsx
122+
<form.Field
123+
name="age"
124+
asyncDebounceMs={500}
125+
validators={{
126+
onBlurAsync: async ({value, signal}) => {
127+
const currentAge = await fetchCurrentAgeOnProfile({signal})
128+
return value < currentAge ? 'You can only increase the age' : undefined
129+
},
130+
}}
131+
/>
132+
```
133+
134+
## Platform support
135+
136+
Not only do we support multiple frameworks as we mentioned from the start; we support multiple runtimes. Whether you're using React Native, NativeScript, or even SSR solutions like Next.js or [TanStack Start](/start), we have you covered.
137+
138+
In fact, if you're using SSR solutions, we even make server-side form validation a breeze:
139+
140+
```typescript
141+
// app/routes/index.tsx, but can be extracted to any other path
142+
import {
143+
createServerValidate,
144+
getFormData,
145+
} from '@tanstack/react-form/start'
146+
import {yourSchemaHere} from '~/constants/forms';
147+
148+
const serverValidate = createServerValidate({
149+
...formOpts,
150+
onServerValidate: yourSchemaHere
151+
})
152+
153+
export const getFormDataFromServer = createServerFn({ method: 'GET' }).handler(
154+
async () => {
155+
return getFormData()
156+
},
157+
)
158+
```
159+
160+
> This code sample excludes some of the relevant code to keep things glanceable. [For more details on our SSR integration, please check our docs.](/form/latest/docs/framework/react/guides/ssr)
161+
162+
And boom, the exact same validation logic is running on both your frontend and backend. Your forms will even show errors when JavaScript is disabled on the user's browser!
163+
164+
# A look forward
165+
166+
We're not resting on our laurels, however - we have plans to add new features to v1 now that we're stable. These features include:
167+
168+
- [Persistence APIs](https://github.com/TanStack/form/pull/561)
169+
- [A Svelte 5 adapter](https://github.com/TanStack/form/issues/516)
170+
- [Better DX for transforming values on submission](https://github.com/TanStack/form/issues/418)
171+
- [Form Groups](https://github.com/TanStack/form/issues/419)
172+
173+
And much more.
174+
175+
176+
# Thank **you**
177+
178+
There's so many people I'd like to thank that once I'd gotten started I'd never end. Instead, I'll address each group of folks I want to thank.
179+
180+
- Thank you to our contributors: So many people had to come together to make this happen. From maintainers of other TanStack projects giving us guidance, to drive-by PRs; it all helped us get across the line.
181+
182+
- Thank you to our early adopters: The ones who took a risk on us and provided invaluable feedback on our APIs and functionality.
183+
- Thank you to the content creators who covered our tools: You brought more eyes to our project - making it better through education and feedback.
184+
- Thank you to the broader community: Your excitement to use our tools have driven the team immensely.
185+
186+
And finally, thank **you** for taking the time to read and explore our newest tool. ❤️
271 KB
Loading

0 commit comments

Comments
 (0)