修复服务端组件中使用 SessionProvider 导致构建失败的问题

This commit is contained in:
wmp
2025-09-17 17:57:22 +08:00
parent 2bf90ee827
commit b39f6677a4
2 changed files with 17 additions and 10 deletions

View File

@@ -1,7 +1,6 @@
import type { Metadata } from "next"; import type { Metadata } from "next";
import "./globals.css"; import "./globals.css";
import { Toaster } from "sonner"; import Providers from "./providers";
import { SessionProvider } from "next-auth/react";
export const metadata: Metadata = { export const metadata: Metadata = {
title: "Create Next App", title: "Create Next App",
@@ -15,14 +14,9 @@ export default function RootLayout({
}>) { }>) {
return ( return (
<html lang="zh-Hans"> <html lang="zh-Hans">
<body <body className={`antialiased`}>
className={`antialiased`} <Providers>{children}</Providers>
>
<SessionProvider>
{children}
<Toaster richColors />
</SessionProvider>
</body> </body>
</html> </html>
); );
} }

13
src/app/providers.tsx Normal file
View File

@@ -0,0 +1,13 @@
"use client";
import { SessionProvider } from "next-auth/react";
import { Toaster } from "sonner";
export default function Providers({ children }: { children: React.ReactNode }) {
return (
<SessionProvider>
{children}
<Toaster richColors />
</SessionProvider>
);
}