Next.js Discord

Discord Forum

client side redirect show a splash before redirect

Unanswered
German Hound posted this in #help-forum
Open in Discord
German HoundOP
i have authention system on which work based on localstorage i want to hide profile page if user is not login i setup the redirect which works fine but it show profile page for a sec then redirect to loginpage i want to dreictly show the login page if user not login here is the code which i use for redirect

      const router = useRouter();
      const { getItem: getAuthUser } = useLocalStorage("authuser");
      const authUserValue = getAuthUser();
      if (!authUserValue) {
        router.push("/login");
      }

0 Replies