Next.js Discord

Discord Forum

Authentication flow in Next.Js with spring boot and firebase

Unanswered
Golden northern bumble bee posted this in #help-forum
Open in Discord
Golden northern bumble beeOP
I'm working on a project using Next.js 15 and Spring. For authentication with Google, I'm using Firebase. Additionally, I manage user profiles on the Spring backend.

I'm currently looking for best practices regarding the authentication flow and how to secure routing.

My app is structured into two separate segments: (auth) and (app).

What I want to achieve is the following:

On each navigation to a protected page (e.g., dashboard, profile page, options, etc.), the app should fetch the user's profile data from the Spring backend.

I don't want to duplicate the profile-fetching logic across multiple pages.

Ideally, I'd like to be able to simply use a hook like const profile = useProfile() wherever needed, and regardless of whether a component uses the profile, the data should always be kept up-to-date in the background.

Also, is using Firebase in this case overkill? I only use it for the Google login flow and nothing else.

1 Reply

Pixiebob
chat.openai.com