Integrating Next-Auth with existing NestJS backend
Unanswered
Dareon posted this in #help-forum
![Avatar](https://cdn.discordapp.com/avatars/732737923706781777/807093054b3a6cd2f09641859c9eb624.webp?size=256)
DareonOP
Hello everyone, I have a question regarding authentication in Next.js. I currently have a custom NestJS backend that handles authentication using JWTs, with refresh tokens stored in a database and Passport.js for handling authentication. Given this setup, would there be any benefit in integrating Next-Auth into my application? Is it even possible to use Next-Auth in this scenario? Additionally, if I were to create a Next.js API endpoint that calls my NestJS backend, would this add significant latency compared to making direct calls from the frontend to the NestJS backend? Any insights would be greatly appreciated!
3 Replies
![Avatar](https://cdn.discordapp.com/guilds/752553802359505017/users/258390283127881728/avatars/6d84d27ad734d86c3c3d7f004660bded.webp?size=256)
Rafael Almeida
If you alredy have a back-end that handles authentication I don't see many reasons to use next-auth. Calling your API through a Next.js API endpoint does introduce a very very small latency but if you need to do it there's no issue, it is very common to proxy APIs to avoid CORS issues
![Avatar](https://cdn.discordapp.com/avatars/732737923706781777/807093054b3a6cd2f09641859c9eb624.webp?size=256)
DareonOP
thanks for the quick response. Considering that I haven't implemented things on the client side yet, then perhaps using the hooks provided by Next-Auth could at the very least speed up my development process? it does handle refreshing of tokens doesnt it
or what would be the (few) reasons for still using Next-Auth, that you can think of?
or what would be the (few) reasons for still using Next-Auth, that you can think of?
![Avatar](https://cdn.discordapp.com/guilds/752553802359505017/users/258390283127881728/avatars/6d84d27ad734d86c3c3d7f004660bded.webp?size=256)
Rafael Almeida
The hooks are the only thing I can think of, I don't really use this library but I am pretty sure you can't integrate it with another API that already handles everything for auth