TanStack

T

TanStack

TanStack is a community of passionate software engineers striving for high-quality, open-source software for web devs

Join

react-query-questions

solid-query-questions

table-questions

virtual-questions

router-questions

react-charts-questions

ranger-questions

vue-query-questions

svelte-query-questions

bling-questions

form-questions

angular-query-questions

start-questions

db-questions

start-showcase

router-showcase

📣-announcements

national-gold
national-gold8/10/2025

Get type inference without using defaultValues

Hello, I am trying not to use defaultValues in my form and resetting the form when the deliveryNote prop changes because I want my form to be synchronized with my data sources, both the deliveryNote and nextAvailableDeliveryNoteIdData are updated in realtime.
foreign-sapphire
foreign-sapphire8/10/2025

form with dependent fields (more complicated than just linking)

i have this sort of UI shown in the image. for the cost field, i'm tracking the raw value, for the splits field, i'm tracking only the percentage value. when it transitions to 'amount' mode, i just compute the value from the percentage of the value in 'amount', and show that. similarly onchange, i just transform the raw value into the proper percentage in the basic cases this is easy. percent mode is no problem, those don't even really care what cost is, where just tracking essentially a proportion. also, when cost is static, this is also easy, the transform cycle above ^, is straightforward enough this gets tricky when you're in amount mode AND change the cost value. this gives me two possible scenarios:...
No description
foreign-sapphire
foreign-sapphire8/9/2025

generic Input element

i have this generic input element i register with the form, and reduces a whole lot of boilerplate, basically i pass down the field and then setup everything else as is, and is configurable from top down the issue is that this really is only working for fields that hold string | number values in the form i have a more complex field that's an array of objects. the field will only track one of the fields, and then i'll have basically a encode decode cycle where...
adverse-sapphire
adverse-sapphire8/9/2025

typing `withForm`

Is this the correct way to type withForm? ```ts import { useAppForm, withForm } from "~/hooks/form"; const PersonalInfoSection = withForm({...
national-gold
national-gold8/7/2025

possible onMount & onChange validation errors bug

I am trying to use onMount and onChange validators with my Zod schema in order to, well, "always" validate the form inputs. I was playing with the official Form and Field validation example in Stackblitz and I ended up in a weeird behaviour: The error messages of the non-edited field are duplicated. I guess this is a bug, right? The picture shows the initial state of the form, which is correct. As soon as you edit one field, e.g. the first one, the second field shows its error message twice! Same issue occurs if you edit the second field first: the first field shows its two error messages twice 😵‍💫 Link to stackblitz reproducible example https://stackblitz.com/edit/tanstack-form-pobqx3yj?file=src%2Findex.tsx...
No description
rival-black
rival-black8/6/2025

Reset form after Submit not working as expected?

So, I have a React App and a simple form and I want to set the default values to whatever the form has at the time of submission. However, doing so resets the form to the original defaultValues, instead of the new ones passed to the function. Is there anything I'm doing wrong? ...
wise-white
wise-white8/5/2025

isDefaultValue

I know we can get the isDefaultValue from the form state, but I don't see anywhere that says if this gets updated to true after a form is submitted successfully. Does it reset this flag? Or is there another way to essentially reset if this form is changed or not after submitting essentially setting the submitted data as the new form defaults?
rare-sapphire
rare-sapphire8/5/2025

Delete Field seems not working

Hello all, I have a complex form and there is a logic realted to one boolean switch field - when it goes false I need to delete some fields of the form not only on UI(this part is working) but on form level as well(this part is not working). I tried form.deleteField method inside listeners of the switch field but despite the fact it is called, still when I submit form the fields I deleted are still arriving as fields of submit value. What can I do with that? Maybe there is an alternative way? Thank you...
mere-teal
mere-teal8/5/2025

Form composition with zod validation

I'm attempting to compose a form with optional components, e.g. in a given form there may or may not be a component that collects customer information. I'd like to add zod validation for each of these components, and then I'll add some conditional logic to render the 'blocks' as needed. I'm attempting to add a second of these components (rental period) but I'm running into some types trouble with the onChange in the validator (fixed by not using z.union() as well as passing the form object as props to the form components. Sorry if the image is confusing, I can add more context if needed. Disclaimer I'm pretty new to React and Tanstack, so I may be conflating terms. Thanks for any help....
No description
rare-sapphire
rare-sapphire8/4/2025

Synchronizing / linking fields in a form

I'm looking for a way to sync the values of two or more fields in a form. Example; There are 3 fields copies, weight and totalWeight. I would like to make them synchronized such that editing the copies field should change the totalWeight and editing one of the weight fields should update the value of the other field....
variable-lime
variable-lime8/4/2025

Better handle for conditional fields with error

Currently it's very cumbersome to use conditional fields, since there's no convenient way to handle errors on them. For example in 99% of the cases we want behavior like this: When all visible (mounted) fields are valid, despite some of the hidden fields have errors, it is considered a valid state. ...
deep-jade
deep-jade8/3/2025

Passing the form's type to a custom hook

I'm currently in the middle of refactoring from React Hook Form to TanStack Form, and I'm struggling to figure out how to pass the form's type to a custom hook. My goal is to abstract logic out of the component — things like inserting data into the form, setting errors, and so on. I've gone through the form composition docs, but they don't seem to cover how to handle this kind of abstraction using custom hooks. Am I missing something fundamental here?...
fascinating-indigo
fascinating-indigo8/1/2025

Question about TanStack Form `formOptions` vs regular object

Hey everyone! 👋 I'm trying to understand the practical difference between using formOptions() vs just exporting a regular object with the same structure in TanStack Form. Using formOptions():...
like-gold
like-gold8/1/2025

"Collect" all errors from nested fields

Is there an idomatic way to get the following to work: ```tsx <form.AppField name="parent"> {(field) => (<div>...
exotic-emerald
exotic-emerald7/31/2025

Idiomatic approach to error handling when `onSubmit` handler rejects?

This has very likely been asked before but couldn't find existing conversations about it. The most relevant example (https://tanstack.com/form/latest/docs/framework/react/examples/query-integration) also doesn't cover this. I'm using @tanstack/react-query so I have something like this for the form setup: ```ts...
other-emerald
other-emerald7/31/2025

Force Blur for Manual Validation (Solved)

Maybe I'm missing something simple, but I'm struggling with handling validation properly in the forms. I need to have it handle so that it only shows the error if the field has been blurred, so that when someone types "t" the entire form just doesn't show errors onChange. Each field will only show the errors when they have been blurred, However, I need to then have the ability to show the errors if the user clicks on the submit button before its valid (my submit will call an onClick instead of submit if the form is not valid). But I don't know how to remove the isBlurred part....
compatible-crimson
compatible-crimson7/31/2025

Server-side vs client-side validation

Which approach is better when working with Tanstack Start and Tanstack Form, is it server-side validation like the link bellow or client-side validation for authentication using Better Auth? https://tanstack.com/form/latest/docs/framework/react/guides/ssr In better auth docs, they recommend using auth client with Tanstack Start: We recommend using the client SDK or authClient to handle authentication, rather than server actions with auth.api...
rising-crimson
rising-crimson7/28/2025

Differential validation in onSubmit depending on onSubmitMeta

Hi! I'm using the onSubmitMeta to include different submitActions for onSubmit: "autosave", "publish" and "unpublish". This gives me the ability to use the isSubmitting and keep it within the form, but I would like to have different validation schemas for the different submitActions, as the user should be able to save their draft without it necessarily being complete, but not be able to publish until all the pieces are in place. I have tried moving the validation to within the onSubmit function...
No description
fascinating-indigo
fascinating-indigo7/28/2025

formIsValid stays false despite all fields being valid?

I have a large form with field-level validation configured to run on blur. I've run into a tricky issue where formIsValid remains false even when all individual fields show isValid: true. The problem flow: ...
No description
genetic-orange
genetic-orange7/28/2025

I need helps with @tanstack/svelte-form. How should I implement confirmation dialog for a dirty form

I need window.confirm to show when leaving the form with unsaved changes. The picture my is the code snippet, can you check that something was wrong?
No description