Redirect to specific route

Hi xeibra,

Thanks for giving more inputs, i tried from my end there are couple of things i can suggest,

  1. Make sure your using @auth0/auth0-react package.
  2. Check once you have configured the URL’s
  3. Please try using the below code once
import { useAuth0 } from "@auth0/auth0-react";
import "./App.css";

const LoginButton = () => {
  const { isAuthenticated, loginWithRedirect } = useAuth0();

  useEffect(() => {
    const checkAuthentication = async () => {
      if (isAuthenticated) {
        console.log("After Login - isAuthenticated:", isAuthenticated);
      }
    };
    checkAuthentication();
  }, [isAuthenticated]);

  const handleLogin = () => {
    // Log isAuthenticated before login
    console.log("Before Login - isAuthenticated:", isAuthenticated);

    loginWithRedirect();
  };

  return (
    <div className="container">
      {!isAuthenticated && (
        <button
          onClick={handleLogin}
          className="login-button"
        >
          Log In
        </button>
      )}
    </div>
  );
};

export default LoginButton;

for the above code post login, isAuthenticated showing as true in console.

image

Regards,
Pavan.

1 Like