Describe the bug
The example code to use TanStack Form with Server Actions in Next has several deficiencies.
It seems that the form submission/calling the action is happening natively and completely skipping the TanStack Form. That means that:
- the form can be cumitted even if it is not valid
formState.isSubmitting is never true
onSubmit function is never exectured, unless you add e.preventDefault() to <form onSubmit>
- And all other things that are related to TanStack Form not being hooked on the Form sumission.
Your minimal, reproducible example
https://github.com/tanstack/form/tree/main/examples/react/next-server-actions
Steps to reproduce
- Checkout the code from https://github.com/tanstack/form/tree/main/examples/react/next-server-actions and run it
- Optionally add
await new Promise(resolve => setTimeout(resolve, 2000)); to ./src/app /action.ts to be able to observe the behaviour easier
- Submit the form.
isSubmitting is never true, so the submit button always remains the same.
Expected behavior
The isSubmitting state should be changed when the form is being submitted.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
- OS: Windows 11
- Browser: Chrome
TanStack Form adapter
react-form
TanStack Form version
v1.27.7
TypeScript version
v5.9.3
Additional context
No response
Describe the bug
The example code to use TanStack Form with Server Actions in Next has several deficiencies.
It seems that the form submission/calling the action is happening natively and completely skipping the TanStack Form. That means that:
formState.isSubmittingis never trueonSubmitfunction is never exectured, unless you adde.preventDefault()to<form onSubmit>Your minimal, reproducible example
https://github.com/tanstack/form/tree/main/examples/react/next-server-actions
Steps to reproduce
await new Promise(resolve => setTimeout(resolve, 2000));to./src/app /action.tsto be able to observe the behaviour easierisSubmittingis never true, so the submit button always remains the same.Expected behavior
The isSubmitting state should be changed when the form is being submitted.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
TanStack Form adapter
react-form
TanStack Form version
v1.27.7
TypeScript version
v5.9.3
Additional context
No response