Nextjs 15 compatibility issues with Authjs
Answered
Orinoco Crocodile posted this in #help-forum
Orinoco CrocodileOP
Hi everyone, I recently upgraded a project from nextjs 14 to the new next 15 and since then i've been getting this error while trying to get the session from authjs anywhere in my appication. Here im current getting the session on the layout file and thats is what's causing this error. i'm using authjs v5
This is the code of my layout file where i'm getting the session:
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import { SessionProvider } from "next-auth/react";
import { auth } from "@/auth";
import "./globals.css";
import { Toaster } from "@/components/ui/sonner";
const inter = Inter({ subsets: ["latin"] });
export const metadata: Metadata = {
title: "Create Next App",
description: "Generated by create next app",
};
export default async function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
const session = await auth();
return (
<SessionProvider session={session}>
<html lang="en">
<body className={inter.className}>
<Toaster />
{children}
</body>
</html>
</SessionProvider>
);
}
Pls is there anything i can do to solve this error currently, or i should just stick to nextjs for now 14 while this issue is being fixed by authjs
This is the code of my layout file where i'm getting the session:
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import { SessionProvider } from "next-auth/react";
import { auth } from "@/auth";
import "./globals.css";
import { Toaster } from "@/components/ui/sonner";
const inter = Inter({ subsets: ["latin"] });
export const metadata: Metadata = {
title: "Create Next App",
description: "Generated by create next app",
};
export default async function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
const session = await auth();
return (
<SessionProvider session={session}>
<html lang="en">
<body className={inter.className}>
<Toaster />
{children}
</body>
</html>
</SessionProvider>
);
}
Pls is there anything i can do to solve this error currently, or i should just stick to nextjs for now 14 while this issue is being fixed by authjs
Answered by Asian black bear
Which exact version of next-auth are you using atm? According to posts on Reddit it was fixed for next-auth 4.24.9 and next-auth 5.0.0-beta.25.
2 Replies
Asian black bear
Which exact version of next-auth are you using atm? According to posts on Reddit it was fixed for next-auth 4.24.9 and next-auth 5.0.0-beta.25.
Answer
@Asian black bear Which exact version of next-auth are you using atm? According to posts on Reddit it was fixed for next-auth 4.24.9 and next-auth 5.0.0-beta.25.
Orinoco CrocodileOP
ok thanks so much.. i was using an older version of next auth. i just upgraded it now and it works 🙏