
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
- Auth Error
"use client"; import { useEffect } from "react"; import { getSessionCookie } from "@/actions/auth"; import { createBrowserSessionClient } from "@/lib/appwrite-...
- Cannot connect to SMTP in AppWrite - set...
This used to work and then at some point it stopped. One thing that happened in that time was moving my application to Vercel. I have read on another thread t...
- Prevent modifying specific attributes
How do I prevent user to only to be able to modify some of the attributes. Document level security gives full access to update whole document, what are the wor...
