Next.js Discord

Discord Forum

is it possible in "app" to use server like imports inside "use client" children components?

Unanswered
Asiatic Lion posted this in #help-forum
Open in Discord
Asiatic LionOP
is it possible in "app" to use server like imports inside "use client" children components?
"server-only";

import { promises as fs } from "fs";
import path from "path";

?
./src/lib/db/db-utils.ts:11:0
Module not found: Can't resolve 'fs'

9 Replies

Asiatic LionOP
Asiatic LionOP
um, chakraprovider component must be in client ?
"Chakra UI components are client-side only"
Asiatic LionOP
i fixed the provider thank you
its just the components, trying to see if i need to put them all in a context.tsx that i import in page.tsx
@Asiatic Lion its just the components, trying to see if i need to put them all in a context.tsx that i import in page.tsx
i dont understand this question, but you can
* import client components to server components
* pass server components as prop (e.g. children) to client components
but you cannot
* import server-side stuff to client components
Asiatic LionOP
i get that yes, server stuff in top page.tsx then render data in child componetns