
TypeScript
Error:
× You're importing a component that needs next/headers. That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/getting-started/
│ react-essentials#server-components
│
│
╭─[P:\web-app\lib\appwrite.ts:1:1]
2 │ import { cookies } from 'next/headers';
TypeScript
useEffect(() => {
const fetchData = async () => {
try {
const model = await loadEmployees()
setEmployees(model.documents as Employee[])
}
} catch (error) {
log.error("Error fetching data SERVER ACTION:", error);
}
}
fetchData();
}, [])
I read the documentation of nextjs , it should be working fine!
TL;DR
Issue with importing a component requiring 'next/headers' in a Server Component not supported in pages/ directory. Make sure to add 'use server' at the top of appwrite.ts file.
did you put 'use server' at the top of your appwrite.ts file?

no. if i put , it getting this error
Recommended threads
- Error while usining domain
While usining domain and im im messaging tab i see: 500 Internal Error But when i use IP:PORT i see this: (Photo) Where is problem The console looks like t...
- Realtime Memory Usage
Appwrite-Realtime container has been acting strangely lately. None of my functions use this feature, but it has been consuming a large chunk of memory. When I s...
- No mails from Appwrite
Hello, Since severals days, i have a problem : i d'ont received any mails from Appwrite. I'm using the auth by mail and i don't any code so any mails from App...
