useFormState and useFormStatus only available in experimental
Unanswered
Dachshund posted this in #help-forum
DachshundOP
Hi folks,
The Next.js App Router documentation for Authentication suggests using
I don't do much React.js or Next.js myself, so maybe I'm misunderstanding quite severely, but an intern I am working with is trying to set up auth in a Next.js 14.0.3 app using App Router and found that
See: https://react.dev/reference/react-dom/hooks/useFormState
Is this simply due to Next.js App Router being very new still? Or is this perhaps a mistake in the documentation?
In any case, we would not like to use Experimental or Canary in our app, we would like to keep it stable if possible. What should I advise my intern to do, instead of using these hooks? Should he just track state manually instead?
Note that he is also looking to use NextAuth.js if that changes anything - he is quite green to React.js and so am I as I don't spend a lot of time programming anymore, mostly just doing project management and DevOps stuff.
Open to any ideas and willing to give more information if needed - just slightly confused about these docs and looking for a hand, thanks in advance.
The Next.js App Router documentation for Authentication suggests using
useFormState and useFormStatus from react-dom, found here: https://nextjs.org/docs/app/building-your-application/authentication under the app/login/page.tsx example snippet.I don't do much React.js or Next.js myself, so maybe I'm misunderstanding quite severely, but an intern I am working with is trying to set up auth in a Next.js 14.0.3 app using App Router and found that
useFormState and useFormStatus are actually still only available in experimental or canary builds of React.js as of 18.2.0 (which we are using).See: https://react.dev/reference/react-dom/hooks/useFormState
Is this simply due to Next.js App Router being very new still? Or is this perhaps a mistake in the documentation?
In any case, we would not like to use Experimental or Canary in our app, we would like to keep it stable if possible. What should I advise my intern to do, instead of using these hooks? Should he just track state manually instead?
Note that he is also looking to use NextAuth.js if that changes anything - he is quite green to React.js and so am I as I don't spend a lot of time programming anymore, mostly just doing project management and DevOps stuff.
Open to any ideas and willing to give more information if needed - just slightly confused about these docs and looking for a hand, thanks in advance.
12 Replies
@riský nextjs app dir does use experimental builds of react but they pin the versions and ensure it works before updating it
DachshundOP
In terms of my app, does this mean I need to upgrade our
react version that's in package.json and if so, how would I go about finding what that pinned version is which Next.js has pinned to? Or have I completely misunderstood youthe version you have in package.json dowsn't do anything
DachshundOP
Ah right so it's just baked in then
nextjs bundles it in their package
DachshundOP
That makes sense
you may just need the types package on a latest so TS doesn't cry
DachshundOP
I was just about to say lol
Perfect thank you so much for your help
no problem
and fwiw those new hooks are amazing
DachshundOP
they look the bomb!