#Nextjs Authentication with Honojs

1 messages · Page 1 of 1 (latest)

small hornet
#

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.

icy wigeonBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

rain nimbus
#

What are those 2 ways

small hornet
#

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:

#

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