I had the same issue, but the culprit was not auth0, or useNavigate, but it was useEffect, my useEffect was running, before the auth0 can catch the code and state and was redirecting, to the same page which was removing the query params from the URL and the auth0 was unable to authenticate the user.