Dashboard
Unanswered
American black bear posted this in #help-forum
American black bearOP
I want to know how im doing if someone without session login to "Dashboard" so that will bring him fast to "login" without wait without loading?
(when i did this that bring only after 5 sec)
(when i did this that bring only after 5 sec)
12 Replies
Plott Hound
How are you handling the redirect?
Can you share your code?
@Plott Hound How are you handling the redirect?
American black bearOP
like if im doing reload so that took secs to check session until the loading is done
I am use useEffect for "getsession"
import { getSession } from "next-auth/react";
import { useRouter } from "next/navigation";
const router = useRouter();
async function checkSession() {
const session = await getsession();
if (!session) {
router.push("/login");
} else {
console.log("passed");
}Plott Hound
Are you using nextjs app router?
It might just be slow for dev. Did you test it in production?
@Plott Hound Are you using nextjs app router?
American black bearOP
Im use page.tsx
Plott Hound
Did you test it in production? Eg vercel?
@Plott Hound Did you test it in production? Eg vercel?
American black bearOP
No , i am testing in localhost
Plott Hound
It’s always quite slow in dev, test it in prod and I’m sure it will be fine
@Plott Hound It’s always quite slow in dev, test it in prod and I’m sure it will be fine
American black bearOP
oh okay