![](https://cdn.discordapp.com/avatars/348666300815638529/1b7de6aeaee66e70ebba9d86a1c27f15.webp)
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. ![](https://cdn.discordapp.com/avatars/186656408450629633/a_1020a50ae94486c09c02e2868564778d.gif)
did you put 'use server' at the top of your appwrite.ts file?
![](https://cdn.discordapp.com/avatars/348666300815638529/1b7de6aeaee66e70ebba9d86a1c27f15.webp)
no. if i put , it getting this error
Recommended threads
- Upgrade to 1.6 not working
Hello. I'm trying to update my self hosted instance from 1.5.7 to 1.6.0 newest version. It worked flawlessly with 1.5.8, 1.5.9 and 1.5.10. But after trying to u...
- Unable to start migration
I am trying to migrate from one self-host to another self-host, but after entering the correct details of the original instance, the resources page starts spinn...
- Can i have conditional statements inside...
As I’m migrating my code from using Supabase to Appwrite, I’ve encountered an issue with migrating the email templates. Supabase uses Go templates, and in one o...
![](/images/bgs/pre-footer.png)