Please help me fix this error: When I run the application in Next.js I am getting this message:
Error: React Context is unavailable in Server Components
import { useSession } from "next-auth/react";
import prisma from "@/lib/prisma";
import { ChatbotClient } from "./components/chatbot-client";
import { redirect } from "next/navigation";
interface ChatbotIdPageProps {
params: {
chatbotId: string;
};
}
const ChatbotIdPage = async ({ params }: ChatbotIdPageProps) => {
const { data: session } = useSession();
if (!session?.user) {
redirect("/demo");
}
const userId = JSON.stringify(session.user);
const chatbot = await prisma.chatbot.findUnique({
where: {
id: params.chatbotId,
userId: userId,
},
});
return <ChatbotClient initialData={chatbot} />;
};
export default ChatbotIdPage;
"use Client";
with capital C in Client, changed to"use client";
and worked – Marathi