Skip to content

require-use-server-in-actions-file

route action module missing the use server directive

Why

An exported async function is not callable as a Server Action merely because its file is named actions.ts. Without the module directive, a client import can fail or pull server-only implementation details across the client boundary.

Fix

Use a leading module directive for an action-only module, or retain a function-level directive for an inline Server Action. Do not turn mixed non-action exports into a Server Action module.

Examples

Before — flagged Do not rely on the filename to create a Server Action
app/orders/actions.ts
export async function cancelOrder() {}
After — preferred Mark the action module as server-only
app/orders/actions.ts
"use server";
export async function cancelOrder() {}