Redirect After Login

Hi, first post here…I’ve got some functionality in place that logs in the user and logs the user out. I’m stuck on finding a way to redirect the user after logging in and logging out. Is there a way to not use react-router? Appreciate any direction on it. Thanks!

Hi @justin

Welcome to the community.

Redirects are easy to do with plain JavaScript - you can use window.location.href to redirect to another webpage and you can call that if a condition that you specify applies. For example:

let userIsLoggedIn = true;

if (userIsLoggedIn) {
   window.location.href = "";


Hi @justin

I realised that my earlier answer would force a page reload, which is probably not what you want.

With Frontity you can use actions.router.set.


Hi @mburridge,

Appreciate confirming that. Works well.

In case others stumble on this thread, I simply implemented it like this:

const Login = ({ state, actions }) => {
... // Fetch logic here and before catch
actions.router.set('/'); // To go back home after logging in.