Next.js Discord

Discord Forum

My layout keeps refreshing data every next/link tap :-( help!

Spectacled Caiman posted this in #help-forum
Open in Discord
Spectacled CaimanOP
import { VisitHistory } from "@/components/history/visit-panel"
import { getClientSession } from "@/lib/client/auth"
import { getChats } from "@/lib/server/history"

export default async function Layout({ children }: { children: React.ReactNode }) {
  console.log("Layout: Getting client session")
  const session = await getClientSession()
  console.log(`Layout: Retrieved session for user ${session?.user?.id || "unknown"}`)
  const chats = await getChats(session?.user?.id || "")
  console.log(`Layout: Retrieved ${chats.length} chats`)
  return <div className="flex flex-col md:flex-row h-full w-full overflow-y-auto">
    <VisitHistory chats={chats} />
export const getClientSession = async () => {
  const session = await getServerSession(authOptions)
  return session

it keeps refreshing every sidebar tap which makes the app super slow. what's the deal? I thought I'm following the right pattern

0 Replies