
Is it a good idea to use Next.js API routes for authentication or is it better to have a separate backend for it?
Using Better Auth as an example, I didn't find a direct recommendation on this in their docs. They have integration guides for both Next.js API routes and Fastify/Express backends.
I assume the separate-backend option might scale better and is preferable when you have more than one client (like web + mobile). I haven't really had the chance to use Next.js API routes for auth, since I've always done it separately - either in a monorepo or without one. Maybe someone who's used that setup could share more about their experience?
I'm not asking because I'm building a specific app - I have an open-source project that's a dashboard starter, and I'm wondering whether I picked the right architectural approach for it. In case anyone's curious, here's the link >!< The repo link is inside a spoiler, in hopes that this post won't be taken as an ad for the GitHub project - that's not my goal here. I've pretty much decided to migrate this project from GraphQL to REST, and now I'm also wondering whether I should ditch the separate backend repo entirely and move everything into Next.js as a single app.