Skip to content

Latest commit

 

History

History
55 lines (42 loc) · 987 Bytes

async-server-action.md

File metadata and controls

55 lines (42 loc) · 987 Bytes

Require functions with the use server directive to be async (react/async-server-action)

💡 This rule is manually fixable by editor suggestions.

Require Server Actions (functions with the use server directive) to be async, as mandated by the use server spec.

This must be the case even if the function does not use await or return a promise.

Rule Details

Examples of incorrect code for this rule:

<form
  action={() => {
    'use server';
    ...
  }}
>
  ...
</form>
function action() {
  'use server';
  ...
}

Examples of correct code for this rule:

<form
  action={async () => {
    'use server';
    ...
  }}
>
  ...
</form>
async function action() {
  'use server';
  ...
}

When Not To Use It

If you are not using React Server Components.