Next.js Discord

Discord Forum

Multi-platform auth. Need to use API route to sign in.

Unanswered
Genio posted this in #help-forum
Open in Discord
Hey everyone,

I'm working on a project where I'm building a website using Next.js for both the frontend and backend, along with a mobile app. The goal is to set up an API route for the mobile app to handle login and get a token for future API requests.

The idea is to have an endpoint like /api/login with the following request body:
{
  "username": "yourUsername",
  "password": "yourPassword"
}


I was thinking of using Clerk because I don't want to handle authentication myself. It would be more secure to use a third-party service for this. My plan was to log in the user through Clerk and then return a token, which I would verify for any subsequent endpoint, like when a user needs to access data.

However, Clerk doesn't currently support backend authentication. I'm looking for ideas or other services that can handle this, showcasing the best approach. If anyone has a similar project or example I could check out, please share!

Any advice, examples, or project links (preferably on GitHub) made with Next.js would be appreciated!

0 Replies