
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
- Database DeleteDocuments triggered via D...
Running self hosted 1.7.4. Have a dart cleanup function that deletes stale documents from a collection. Recently updated the function to use DeleteDocuments ins...
- Microsoft Oauth2 gets auto disabled
I'm runnin appwrite self hosted 1.7.4 and once every few hours the provider keeps getting disabled for whatever reason. I don't see anything in the logs and wo...
- Blob column?
Hi, I'm looking to use yjs/hocuspocus, and appwrite as the backend store, but I'm not finding a way to create a blob column in the database. Is there a way arou...
