using the useSession hook with react/next
Code for context:
Component
I get this type error in VSCode
Not sure if this is relevant but if I run it anways i get a 404 on
http://localhost:3001/api/auth/use-session
in the network tab, I think its supposed to be calling get-session but i'm not sure why the hook from the library is doing this.Solution:Jump to solution
Okay I figured it out, useSession only works if your are using better auth and next as full stack not if you have your better auth backend on express and just using next as a front end.
3 Replies
Did you add the api router into your project?
src/app/api/auth/[...all]
We have
app.all("/api/auth/*", toNodeHandler(auth));
is there smth else we need to add?
Login and everything works just fine fyi its just usign the useSession hook on FESolution
Okay I figured it out, useSession only works if your are using better auth and next as full stack not if you have your better auth backend on express and just using next as a front end.