0

I have 2 problems.

  1. I want it to automatically redirect to /signin page when I start the project.
  2. I want to prevent someone who is not logged in from accessing the homepage.

I am using aws amplify for authentication and know there is no problem. I have no problem logging in. I want to use something like this Auth.currentSession ? (navigate = "/homepage") : (navigate = "/signin") Can you help me?

App.js

function App() {
  const ref = useRef(null);
  const navigate = useNavigate();
  return (
    <BrowserRouter>
      <Routes>
        <Route path="/signin" element={<SignIn />}></Route>
        <Route path="/signup" element={<SignUp />}></Route>
        <Route path="/homepage" element={<HomePage />}></Route>
      </Routes>
    </BrowserRouter>
  );
}
Drew Reese
  • 103,803
  • 12
  • 69
  • 96

0 Answers0