NextJS + custom backend (NestJS)
-
Hi folks,
I've been reading https://fusionauth.io/docs/quickstarts/quickstart-javascript-nextjs-web and then I realized that it is communicating directly with FusionAuth. Which means that we where providing it our client secret. I am cool with that idea however I was wondering if that does mean that I can now wipe out my backend RESTful APIs since they are not needed anymore. I mean I can keep them or at least the ones for mobile.
But in general I was not sure anymore about these endpoints.
I guess it boils down to whether I need full control over generating JWT tokens and things like that. Or maybe I am missing some points .
I also loved the
@fusionauth/react-sdk
but like I mentioned it is not working and I dunno how to fix it either. I appreciate it if you could help me with that too. -
I've also read:
But none of them where what I needed. Though I jot down some comments there too .
-
Like I mentioned before I tried the docs and I ended up with another bump along the way. It seems like FusionAuth integration with NextJS is not the best idea. Maybe it's time to switch gears and try SPAs ?
-
We have an open issue for it in
@fusionauth/react-sdk
: https://github.com/FusionAuth/fusionauth-javascript-sdk/issues/99. But it might not be the answer if you are looking for an answer that utilizesnext-auth
. -
@kasir-barati It depends on what you are trying to do. If you are trying to authenticate a user for your application and the login flow that redirects to FusionAuth and returns to your application works, then you would not need the APIs. Even if you need to customize the JWT, I would look into lambdas for that.
-
Thanks @mark-robustelli for your pointers, although I know how we can leverage lambda functions to customize our JWT tokens but I dunno if we can use them to change what
GET /me
endpoint returns. That's part of the reason I opt to develop my own backend to communicate with FusionAuth. -
@kasir-barati When you say "I dunno if we can use them to change what Get /me endpoint returns", you might want to check out the UserInfo Populate Lamba.