Nextjs Authentication with Honojs
Unanswered
West African Crocodile posted this in #help-forum
West African CrocodileOP
Hello, is there anyone who has time to help me understand something about NextJS with a separate backend? The issue is about authentication. I found two ways to do something, but I don't know which one is correct. Thanks in advance to anyone who takes the time.
12 Replies
What are those 2 ways
West African CrocodileOP
Well, up until now I'd only used AuthJS along with NextJS for the Auth part.
But now I've decided to use a backend like HooJS outside of NextJS. I've been guided by some documentation and found different ways to do it, but I still don't have a clear idea.
i call the following route:
But now I've decided to use a backend like HooJS outside of NextJS. I've been guided by some documentation and found different ways to do it, but I still don't have a clear idea.
i call the following route:
and on the frontend I have the google button to log in or create an account
This code opens a pop-up window to select the account and sets the token in the cookies.
But there is something I don't understand or it is not clear to me here the user uses the nextjs api folder and creates the following directory app/api/auth/session/route.ts
What's not clear to me is that the api/auth/session part seems redundant. Wouldn't it be the same as creating a "use server" function that sets the token instead of creating the api folder in nextjs itself? Something like this:
modified form or 2nd form
1 form