SignOut function doesn't immediately re-invoke session change

Hi, everyone
I am currently implement auth in my project
I followed the quick start from docs and it went smoothly
But when I implement sign out and click it, it doesn't immediately show logged out display instead I have to reload the page to see the change?

Here's my
auth.ts
file:
import { headers } from "next/headers";
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";

import { db } from "@/db";
import { user, account, session, verification } from "@/db/schema/user";
import { env } from "@/env";

export const auth = betterAuth({
  database: drizzleAdapter(db, {
    provider: "pg",
    schema: {
      user: user,
      account: account,
      session: session,
      verification: verification,
    },
  }),
  socialProviders: {
    google: {
      clientId: env.GOOGLE_CLIENT_ID,
      clientSecret: env.GOOGLE_CLIENT_SECRET,
    },
  },
});

export const currentUser = async () => {
  const session = await auth.api.getSession({
    headers: await headers(),
  });

  return session?.user;
};


Thx for anyone's help!!!
Solution
export default async function MainLayout({
    children,
}: Readonly<{
    children: React.ReactNode;
}>) {

    const session = await auth.api.getSession({ headers: await headers()})

    return (
        <>
            <Header session={session} />
            <main className="container mx-auto">
                    {children}
                <Footer />
            </main>
        </>
    );
}


This is my code
Was this page helpful?