Next.js Discord

Discord Forum

Unhandled Runtime Error

Unanswered
Bombay-duck posted this in #help-forum
Open in Discord
Bombay-duckOP
im using nextauth to make a basic authentication system with the google API with Firebase

and the response i keep getting is:

Call Stack
SessionProvider
node_modules/.pnpm/next-auth@4.24.7_next@14.2.5_react-dom@18.3.1_react@18.3.1/node_modules/next-auth/react/index.js (451:1)

2 Replies

Tonkinese
can you show how you are using the SessionProvider
@Tonkinese can you show how you are using the SessionProvider
Bombay-duckOP
import type { Metadata } from "next";
import { getServerSession } from "next-auth";
import { Inter as FontSans } from "next/font/google";
import "./globals.css";
import { cn } from "@/lib/utils";
import { authOptions } from "@/pages/api/auth/[...nextauth]";
import Login from "./login/page";
import { SessionProvider } from "next-auth/react";

const fontSans = FontSans({
  subsets: ["latin"],
  variable: "--font-sans",
});

export const metadata: Metadata = {
  title: "Taskiez",
  description: "Taskiez Project Development",
};

export default async function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  const session = await getServerSession(authOptions);

  return (
    <html lang="en" suppressHydrationWarning>
      <head />
      <body
        className={cn(
          "min-h-screen bg-background font-sans antialiased",
          fontSans.variable
        )}
      >
        <SessionProvider session={session}>
          {!session ? (
            <Login />
          ) : (
            children
          )}
        </SessionProvider>
      </body>
    </html>
  );
}