Skip to main content

Redirect the user to a specific route post login

By default, the user is redirected the the / route on your website post login. To change this, you can use the getRedirectionURL function on the frontend as shown below:

SuperTokens.init({    recipeList: [        ThirdPartyEmailPassword.init({            getRedirectionURL: async (context) => {                if (context.action === "SUCCESS") {                    if (context.redirectToPath !== undefined) {                        // we are navigating back to where the user was before they authenticated                        return context.redirectToPath;                    }                    return "/dashboard";                }                return undefined;            }        }),    ]});

The user will be redirected to the provided URL on:

  • Successful sign up
  • Successful sign in
  • Successful email verification.
  • If the user is already logged in.
info

Please refer to this page to learn more about the getRedirectionURL hook.