NextAuth load time
Unanswered
Spotted Redshank posted this in #help-forum
Spotted RedshankOP
Hi I'm using nextAuth with the discord provider, I got it working but on each page reload it takes a bit to actually load the session. Is this normal?
"use client"
import { SessionProvider } from "next-auth/react"
export default function Layout({
children,
session = null, // get session from props
}: {
children: React.ReactNode,
session?: any // make session optional
}) {
return (
<SessionProvider session={session}>
{children}
</SessionProvider>
);
}"use client"
import { useSession, signIn, signOut } from "next-auth/react"
import { Suspense, useEffect, useState } from "react"
export default function Dashboard() {
const { data: session } = useSession();
const [isLoading, setIsLoading] = useState<boolean>(true);
useEffect(() => {
if (session) {
setIsLoading(false);
}
}, [session]);
return (
<>
{
isLoading ? (
<div>
<h1>Loading...</h1>
</div>
) : (
<div>
<h1>Dashboard</h1>
</div>
)
}
</>
);
}3 Replies
Spotted RedshankOP
Also I don't think I can really catch none logged in users this way.
Spotted RedshankOP
Any idea? or is it nomral?
normal