Uncaught (in promise) Error: Invalid state after social login redirect

After logging in with a social connection (e.g. Continue with Google), the app threw Uncaught (in promise) Error: Invalid state from handleRedirectCallback in auth0-spa-js. The login itself succeeded, but processing the redirect back failed. This happened when the redirect callback URL still carried the code and state query parameters and the callback ran more than once.

The fix is to clear the query parameters right inside your onRedirectCallback so the callback cannot be re-processed: call window.history.replaceState({}, document.title, window.location.pathname) in the callback. Multiple reporters confirmed this resolved the Invalid state error. The underlying cause is the SDK re-reading stale code/state params from the URL on a second pass, so stripping them immediately after handling the redirect prevents it. Source: https://github.com/auth0/auth0-spa-js/issues/245

Source: https://github.com/auth0/auth0-spa-js/issues/245