You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’m integrating @tanstack/react-form v1.15.2 with Supabase Auth inside a Next.js 15 server action.
When credentials are wrong, I want to return the Auth error as form-level and form-level messages.
import{ServerValidateError}from'@tanstack/react-form/nextjs'// … inside the server actionconst{ error }=awaitsupabase.auth.signInWithPassword(creds)if(error){thrownewServerValidateError<Credentials,undefined>({formState: {// field-level errorserrorMap: {onServer: {fields: {email: [{message: error.message}],password: [{message: error.message}],},},},// form-level errors (I’d like to keep these too)errors: {email: [{message: error.message}],password: [{message: error.message}],},},})}
At runtime this works — the client receives the messages and displays them — but TypeScript complains:
TS2322 – Type '{ fields: { email: { message: string; }[]; password: { message: string; }[]; }; }'
is not assignable to type 'undefined'.
TS2353 – Object literal may only specify known properties, and'email' does not exist in type 'undefined[]'.
(types.d.ts:27:5) → property 'onServer' expected 'undefined'
(types.d.ts:248:5) → property 'errors' expected string[]
So both errorMap.onServer.fields and errors trigger type errors.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone 👋,
I’m integrating @tanstack/react-form v1.15.2 with Supabase Auth inside a Next.js 15 server action.
When credentials are wrong, I want to return the Auth error as form-level and form-level messages.
At runtime this works — the client receives the messages and displays them — but TypeScript complains:
So both
errorMap.onServer.fields
anderrors
trigger type errors.Relevant versions
Question
What is the correct, type-safe way to:
1, Attach field-level errors messages coming from Supabase
Thanks a lot for any guidance!
Beta Was this translation helpful? Give feedback.
All reactions