Server Actions in Client Components
Troubleshooting errors related to server actions in client components.
You may use Server Actions in client components, but sometimes you may encounter the following issues.
Issue
It is not allowed to define inline "use server" annotated Server Actions in Client Components.
Solution
To use Server Actions in a Client Component, you can either:
- Export them from a separate file with
"use server"at the top. - Pass them down through props from a Server Component.
- Implement a combination of
createAIanduseActionshooks to access them.
Learn more about Server Actions and Mutations.