docs: general docs updates #2118
Openharry-whorlow(GitHub profile, opens in a new tab)wants to merge 6 commits into
main fromssr-docsopened harry-whorlow(GitHub profile, opens in a new tab) changed the title
- @@ -0,0 +1,4 @@1+---2+id: ssr3+title: TanStack Form - TanStack Start4+---@@ -0,0 +1,14 @@1+---2+id: ssr3+title: TanStack Form - TanStack Start4+---5+6+## Using TanStack Form in TanStack Start7+8+ Before reading this section, it's suggested you understand how TanStack `serverFunctions`. [Check out TanStack docs for more information](https://tanstack.com/start/latest/docs/framework/react/guide/server-functions)9+10+### TanStack Start Prerequisites11+12+Start a new `TanStack Start` project, following the steps in the [TanStack Start Quickstart Guide](https://tanstack.com/router/latest/docs/framework/react/guide/tanstack-start)13+Install `@tanstack/react-form`14+Install any [form validator](./validation#validation-through-schema-libraries) of your choice. [Optional]@@ -0,0 +147,21 @@147+ </div>148+ )149+ }}150+ </form.Field>151+ <form.Subscribe152+ selector={(formState) => [formState.canSubmit, formState.isSubmitting]}153+ >154+ {([canSubmit, isSubmitting]) => (155+ <button type="submit" disabled={!canSubmit}>156+ {isSubmitting ? '...' : 'Submit'}157+ </button>158+ )}159+ </form.Subscribe>160+ </form>161+ )162+}163+```164+165+### useTransform166+167+you may have noticed util function `useTransform` being used throughout these examples, it's primary responsibility is the merging of the server and client state. Under the hood it is a useCallback whose deps are that of the server state, when the server state changes it will automatically patch the client state.
- @@ -102,3 +102,5 @@102102 })103103 }104104 ```105+106+ In a situation where you want to be able to submit in a invalid state `canSubmitWhenInvalid` boolean flag can be provided to useForm.@@ -97,3 +97,5 @@9797 <!-- ... -->9898 </template>9999 ```100+101+ In a situation where you want to be able to submit in a invalid state `canSubmitWhenInvalid` boolean flag can be provided to useForm.
- docs/framework/react/guides/arrays.md line 57@@ -52,3 +52,6 @@5252 </form.Field>5353 ```545455+## Why Index as Key?56+57+You may notice that these examples use `key={i}` the array index as the key prop. React's documentation generally advises _against_ using array indices as keys when items can be reordered or deleted. TanStack Form is an exception to this rule. Because field names in TanStack Form arrays are index-based, using the array index as `key` is required, it keeps React component instances, form store state, and field names in sync.docs/framework/react/guides/nextjs.md line 150@@ -0,0 +130,21 @@130+ </div>131+ )132+ }}133+ </form.Field>134+ <form.Subscribe135+ selector={(formState) => [formState.canSubmit, formState.isSubmitting]}136+ >137+ {([canSubmit, isSubmitting]) => (138+ <button type="submit" disabled={!canSubmit}>139+ {isSubmitting ? '...' : 'Submit'}140+ </button>141+ )}142+ </form.Subscribe>143+ </form>144+ )145+}146+```147+148+### useTransform149+150+you may have noticed util function `useTransform` being used throughout these examples, it's primary responsibility is the merging of the server and client state. Under the hood it is a useCallback whose deps are that of the server state, when the server state changes it will automatically patch the client state.
Sign in to join this conversation.
Note
Reviews paused#
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
reviews.auto_review.auto_pause_after_reviewed_commitssetting.Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.Use the checkboxes below for quick actions:
📝 Walkthrough
Walkthrough#
Removed the combined SSR guide and replaced it with three separate React framework guides (TanStack Start, Next.js, Remix); updated docs navigation; added array key rationale; added submission-handling docs for multiple frameworks; deleted
docs/framework/react/guides/ssr.md.Changes#
docs/framework/react/guides/tanstack-start.md,docs/framework/react/guides/nextjs.md,docs/framework/react/guides/remix.mdformOptions, server-side validation patterns usingcreateServerValidate/ServerValidateError, examples for merging server state into client viauseTransform/merge, and example client submission flows per framework.app/routes/index.tsxformOpts(formOptions(...)), server POST handlerhandleForm, server GETgetFormDataFromServer, and exportedRoute(file route) — server-side validation and client merge flows illustrated in examples.docs/framework/react/guides/ssr.mddocs/framework/react/guides/arrays.mdkey={i}for array items due to index-based field names and instance/state alignment.docs/config.jsonuseTransformreference from React functions list.docs/framework/react/guides/submission-handling.md,docs/framework/solid/guides/submission-handling.md,docs/framework/vue/guides/submission-handling.md,docs/framework/angular/guides/submission-handling.mdcanSubmitWhenInvalidboolean option for form creation/injection across React, Solid, Vue, and Angular with example snippets demonstrating submission when invalid.Sequence Diagram(s)#
mermaid sequenceDiagram participant Client participant Server participant FormLib Note over Client,FormLib: Client mounts form with useForm + useTransform Client->>Server: Submit form (Server Action / POST) Server->>Server: createServerValidate -> validate request alt Validation fails Server-->>Client: Return ServerValidateError with e.formState Client->>FormLib: useTransform merges server formState into client store else Validation succeeds Server-->>Client: Success / redirect end
Estimated code review effort#
🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem#
🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)#
✅ Passed checks (1 passed)
✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share