"[object Object]" is not valid JSON

i am using nextjs 15.3.1 app router with typescript, betterauth 1.2.7.

import { auth } from "@/lib/auth";
import { headers } from "next/headers";
export default async function Home() {
  const session = await auth.api.getSession({
    headers: await headers(),
  });
  console.log({ session });
  // rest of the page code
}

Why am i getting SyntaxError: "[object Object]" is not valid JSON in log?

Also, getting the same error in this log on the server (in browser console it gives error FAILED_TO_GET_SESSION)
"use client";
import { authClient } from "@/lib/auth/auth-client";
export default function UserBtn() {
  const data = authClient.useSession();
  console.log(data);
  // rest of the component code
}


i am following betterauth docs exactly. is there any error in nextjs or better auth or my code?
Solution
thanks @KiNFiSH . this fix worked for me -
get: async (key) => {
  const value = await redis.get(key);
  return JSON.stringify(value) || null;
},
Was this page helpful?