Authentication to existing backend with SSR
Unanswered
Masai Lion posted this in #help-forum
Masai LionOP
Hi there! I have an existing backend that authenticates users via credentials and provides a JWT / cookie / whatever is needeed.
I'm struggling to understand how this authentication would work in a SSR scenario.
I'd like the website to be mostly SSR to improve speed, but at this point I would have to have user authentication both in client and server components to talk to the actual backend.
I don't want to have multiple auth layers, how would Next fit into this?
Could NextAuth fit the bill?
I'm struggling to understand how this authentication would work in a SSR scenario.
I'd like the website to be mostly SSR to improve speed, but at this point I would have to have user authentication both in client and server components to talk to the actual backend.
I don't want to have multiple auth layers, how would Next fit into this?
Could NextAuth fit the bill?
4 Replies
Golden-winged Warbler
yes, it should, consider that many of the providers are external to a next app anyhow
Masai LionOP
I'm combing trough the documentation but I still don't quite understand a few things.
I have a backend that holds the business logic and data, I need my users to perform API calls to said backend, so my client (Next) needs to authenticate users to the backend, store JWT, refresh tokens, user information, be able to handle refresh, and provide the token each time a request is made to the backend, be it via a client or server component.
Is this feasible without too much hassle?
I have a backend that holds the business logic and data, I need my users to perform API calls to said backend, so my client (Next) needs to authenticate users to the backend, store JWT, refresh tokens, user information, be able to handle refresh, and provide the token each time a request is made to the backend, be it via a client or server component.
Is this feasible without too much hassle?
Golden-winged Warbler
possible, should be, how much effort, cannot say without understanding your setup more.
I would generally think the next-auth side of things will be mostly about providing login components and proxying the auth calls to your existing backend
I would generally think the next-auth side of things will be mostly about providing login components and proxying the auth calls to your existing backend
The details will also depend on the auth method (i.e. creds vs oauth), I think most of the auth flow will happen in the callbacks