Sarahrb
Sarahrb

Reputation: 669

Landing page URL should be redirected to "/home"

Current landing page URL after login - 'www.website.com'. But I want it to be redirected to "www.website.com/home" upon login. So it has to be redirected to home component.

Upvotes: 0

Views: 530

Answers (3)

mohammad mohammadi nodhe
mohammad mohammadi nodhe

Reputation: 2008

you could simply redirect "/" to "/home"

Upvotes: 0

LutherW
LutherW

Reputation: 369

If you have a solution to check if the user is log you can do that

<Route exact path="/">
  {loggedIn ? <Redirect to="/home" /> : <LoginPage />}
</Route>

If not, you need to redirect to '/home' after login directly after the function of log (in the .then() if you'r loginAction is promise or just after login function). With React Router v5 : history.push('/home') With React Router v6 : navigate('/home') See the doc of React Router if you need more explanation.

Upvotes: 0

Kruzt
Kruzt

Reputation: 71

Maybe you can just change your path from "/" to "/home"?

Upvotes: 0

Related Questions