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

harsh-harlequin
harsh-harlequin7/15/2025

Late validation on linked field

I am facing an strange issue in my Form using zod and refine a schemaa. 1. I have this schema ``` z .number({...
optimistic-gold
optimistic-gold7/14/2025

props.validate is not a function

Hi guys! I'm out of my wits trying find a solution for this error. And I'm using version: "@tanstack/react-form": "^1.14.1",...
No description
xenophobic-harlequin
xenophobic-harlequin7/11/2025

Best practice for sharing validation logic across reusable components in TanStack Form

Hi all, I'm investigating adopting TanStack Form for form composition within our React application. I've successfully composed a field component using TanStack Form, but I'm struggling to understand the best approach for including validation logic with reusable components. For example, I have a complex use case involving a coordinate input form (it allows text input, as well as selection via clicking on a map). Currently, the validation logic is built directly into the React component itself. Each time a user changes the value, it validates whether the coordinate is valid. ...
extended-salmon
extended-salmon7/11/2025

propagating errors to global error boundary

I am running a queryClient.fetchQuery inside of an onChange validator... when it throws a server error, I want it to use my global error boundary, but I'm noticing that it's getting swallowed and is just getting set to the localized error object, is there a way around this?
conscious-sapphire
conscious-sapphire7/10/2025

Conditional zod schema on onSubmit form validator

Probably a skill issue but Is it possible to handle 2 zod schemas conditionally ? export const createEmployeeSchema = z.object({ email: z.string().email(), password: z.string().min(8),...
No description
vicious-gold
vicious-gold7/10/2025

How to set default values asynchronously when using withForm?

I have a pretty big form that is split into smaller chunks by using "withForm", but now I'd like to set default values asynchronously. Is it even possible?
afraid-scarlet
afraid-scarlet7/9/2025

Validation not triggering correctly for conditionally rendered fields

Quick note upfront: I know this is a “me” problem, not a TanStack Form issue 😄 — but I could use some help figuring it out. I’m running into a validation issue with conditionally rendered fields. For example, I have a radio button that toggles between “Yes” and “No.” When “Yes” is selected, additional form fields are shown — but those fields don’t trigger validation until I click somewhere on the screen or focus a field. The same thing happens when I dynamically add fields to a field array. The validation does happen, but only after I interact with the form again (like clicking or focusing somewhere)....
generous-apricot
generous-apricot7/9/2025

Validate object field as a single value with Zod

I'm building a form to create an organization in my project. The form includes an address field, which is an object, as shown in the attached schema. The issue I'm facing is with how validation errors are handled. When I submit the form, the errors returned by props.formApi.getAllErrors() put all the address-related errors into form.errors, instead of nesting them under fields.address. Currently, the only way I can validate the address field as an object is by attaching the validator directly to the field itself. However, this approach causes only the address field to be validated on submit (if there is an error on this field), not the entire form....
No description
metropolitan-bronze
metropolitan-bronze7/9/2025

using useFieldContext with an Object

Hey, couldn't find any info on this, is this the correct/a possible way to work with objects? I know I could do name="object.property", however I probably want to be able to change multiple properties of the same object in 1 component This is my component: ```js import { useFieldContext } from "@/hooks/form";...
deep-jade
deep-jade7/9/2025

SSR Validation lost typesafety

Hello guys, i've tried to refactor my signup form with TanStack Form. I'm using Remix.run so it's submitting a form and i'm getting the data back using useActionData. I have followed the official documentation on how to implement that with Remix.run. I have used Zod schema in onServerValidate and tried to improve the typesafety but to no avail. Why is the type of const formErrors = useStore(form.store, (formState) => formState.errors) equal to undefined[]? I have followed the type definitions and the generic parameter of formState is defined as ...
ambitious-aqua
ambitious-aqua7/9/2025

Cannot get the same form instance with the same type.

Hello all. I set up the form the way it is described in the docs using createFormHook and createFormHookContexts. However my form is way to big. So on the go I decided to split into sections, asuming that I can get form from context. so the structure is like that: ...
No description
silky-coral
silky-coral7/8/2025

How to validate before submit

As you can see, I have a form where I’ll be submitting a server action. I don’t want my submit button to be disabled (only when isSubmitting = true). However, when clicking the button, I’d first like to validate the form, and if isValid = false, I want to prevent the submit. By the way, could you also take a look and let me know whether my form makes sense in general? Am I invoking the server action correctly?...
No description
afraid-scarlet
afraid-scarlet7/7/2025

Inconsistent validation timing - first field validates onBlur, subsequent fields validate onChange

Issue Title TanStack Form: Inconsistent validation timing - first field validates onBlur, subsequent fields validate onChange ...
optimistic-gold
optimistic-gold7/7/2025

How should I handle my validator using Zod 4 when it uses z.coerce?

I want the form to load empty without anything preselected, and then enforce that the age is required. I'm upgrading from Zod 3 and it seems the v4 coerce returns unknown. All the validations work correctly, but I'm getting a type error
The types of 'input.age' are incompatible between these types. Type 'unknown' is not assignable to type 'number'.
This is my useForm hook...
sensitive-blue
sensitive-blue7/7/2025

How to correctly type errorMap?

In my project, I have the following type definitions: `export type ValidationSchemaType = typeof validationSchema; export type FormFields = keyof z.infer<ValidationSchemaType>; export type ReceiptFormType = ReturnType<...
complex-teal
complex-teal7/5/2025

form.state.isValid/ isFormValid / isFieldsValid is true, form.state.errors is empty, zod schema

Hello, I am trying to disable the save button of a form when the description field is empty. I guess I have to use either form.state.isValid or .isFormValid or isFieldsValid, any of the three options 😵‍💫 but they are always true, even when I see the zod validation error My form: ```ts const form = useForm({...
No description
sensitive-blue
sensitive-blue7/4/2025

Use app field components inside another field component

Hi there. I'm stuck in form composition. I'm building a form where I definitely need form composition - it's where I'm struggling. Here, a component with withForm ...
conscious-sapphire
conscious-sapphire7/4/2025

Prop Drilling Necessary?

Hi folks. I'm looking into taking on a pretty large migration Tanstack Form from react-hook-form because we've realized how horrible of a library it is. Many footguns, implementation traps, etc, etc. react-hook-form embraces global hooks quite a bit, and to make the migration a bit simpler I was hoping to emulate that a bit in Tanstack form, but I've noticed the types are basically impossible to work with. It seems like this is by design, and the API forces you to prop drill the form prop anywhere you need it via the withFormhelper. Basically, I'd like to confirm this suspision? Is it unreasonable to use this library if I'm planning on storing the form in context?...
plain-purple
plain-purple7/3/2025

Is there a way to get the type of a form and form state from form options?

I'm trying to create a generic stepper form where certain parts are only visible if other parts are complete or have certain answers. Currently I'm doing this with nested <form.Subscribe> components, but it's pretty ugly. I'm hoping to do something like this: ```ts export type Step<FormOpts, StepId extends string> = { id: StepId;...
rival-black
rival-black7/3/2025

Change value of a field based on another field

I have form with some questions. I am making the field disabled if checkbox isnt checked. I want to make this possible via tanstack-form but couldnt manage to do it except useEffect. Any suggestions?
No description