I'm trying to use React Server Component (with NextJS 13) in Chakra UI but I think it's not yet possible.
From Chakra UI docs (https://chakra-ui.com/getting-started/nextjs-guide):
In my example I would like to fetch data in a Server Component and then render it
import { Text } from "@chakra-ui/react";
async function getData() {
const res = await fetch("http://localhost:3000/api/products");
if (!res.ok) {
throw new Error("Failed to fetch data");
}
return res.json();
}
export default async function Page() {
const data = await getData();
return <Text>{data.length}</Text>;
}
As expected I get an error:
./node_modules/@chakra-ui/accordion/dist/chunk—JDQBKIKM.mjs ReactServerComponentsError: You're importing a that needs useState. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.
since I'm trying to import only client compatible component (Text) in my Server Side Component.
Any solution ?