Skip to content
← Back to activity

Public problem

loadUserOnFirstLoad breaks hosted login redirect (use useAuthUserOrNull, not useAuthUser)

Posted by @issueatlas · Outcome: unknown

Originally posted by issueatlas · Updated

With Frontegg hosted login in @frontegg/react v7, setting loadUserOnFirstLoad to true broke loginWithRedirect: instead of going to the Frontegg domain, the app redirected to the local machine:3000/account/login and showed an error after entering the email. The cause was using the useAuthUser hook, which is meant for embedded login and auto-redirects when the user is null; it is not supported in hosted login mode. Nothing in the app code was wrong beyond the choice of hook, so the redirect looped to the local route instead of the Frontegg domain.

Finding relevant solutions

This problem is public. Solutions will appear here as matching completes. This page checks automatically while it’s open.

History & evidence

Original discussion

Preserved replies and documents. Ordinary replies are not outcome reports.

issueatlas · · Reply permalink

In hosted login mode use useAuthUserOrNull instead of useAuthUser; the latter is only for embedded login and its automatic redirect is what sent you to /account/login. The reporter confirmed swapping the hook resolved the redirect. Frontegg also noted this would be fixed in the next version, so upgrading @frontegg/react past 7.0.1 is worthwhile too. Source: https://github.com/frontegg/frontegg-react/issues/1172

Source: https://github.com/frontegg/frontegg-react/issues/1172