Skip to content
Source
Sign inSign up
TanStack/form

svelte, angular and lit adapters have no SSR-safe default formId #2388

Send to my agent
Openharshit-d3v(GitHub profile, opens in a new tab) opened this issue 0 comments

FormApi falls back to uuid() when no formId is passed:

// packages/form-core/src/FormApi.ts
this._formId = opts?.formId ?? uuid()

That value is random per instance, so the server render and the client render disagree on it. Binding it (id={form.formId}) then produces a hydration mismatch.

React and Preact have always passed an SSR-safe id. #2259 and #2263 added one for Vue and Solid. Three adapters still pass options straight through and never supply a fallback:

AdapterSSR-safe default formId
react-formyes, React.useId
preact-formyes, useId
vue-formyes, since #2259
solid-formyes, since #2263
svelte-formno
angular-formno
lit-formno

grep -r formId packages/<adapter>/src returns nothing for those three, and each returns the FormApi instance directly, so form.formId is reachable from user code.

SvelteKit is the case I'd worry about, since SSR is on by default there.

Before I send anything: do you want the same treatment for these three? Svelte is the awkward one. $props.id() needs Svelte 5.20 while the peer range is ^5.0.0, and it is a compile-time rune so it cannot be feature-detected off the namespace the way vue-form does with Vue.useId. I would rather agree on the approach than guess. Happy to leave angular and lit out if their hydration does not care about a mismatched id.

Sign in to join this conversation.