TanStack / TanStack/form

[react-form-start] Cannot restore form state after post-validation submission errors

Open
#2,272 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

v1 v2: needs investigation
Dominant language
TypeScript
Stars
6.7k
Forks
682
Avg merge
5d 18h
Merged PRs (30d)
7

Description

Observed behavior

With a native TanStack Start form:

<form action={submitForm.url} method="post">

createServerValidate correctly preserves values and errors when server validation fails.

However, if validation succeeds and the subsequent mutation returns a domain error, there is no public API to persist an arbitrary ServerFormState across the redirect:

const values = await serverValidate(formData);
const result = await createResource(values);

if (!result.success) {
  // Cannot restore `values` with field/form errors after redirecting.
}

Returning the form state from the server function navigates the browser to the raw server-function response instead of restoring the original form.

Expected behavior

@tanstack/react-form-start should provide a public API to persist an arbitrary ServerFormState and redirect back to the form, using the same restoration mechanism as createServerValidate.

This would allow post-validation mutation errors to preserve submitted values and populate form-level or field-level errors after the POST/Redirect/GET cycle.

Version: @tanstack/react-form-start@1.33.3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing createServerValidate and the ServerFormState restoration flow in @tanstack/react-form-start, focusing on native POST forms and the redirect cycle. Define how an arbitrary state from a post-validation mutation error can be persisted and restored without navigating to the raw server-function response. Done means form values and field-level or form-level errors survive the POST/Redirect/GET flow through a public API.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.