> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# async-server-action

[Added in v0.9.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.4)
## Configuration


```ts title=rslint.config.ts
import { defineConfig, reactPlugin } from '@rslint/core';

export default defineConfig([
  reactPlugin.configs.recommended,
  {
    rules: {
      'react/async-server-action': 'error',
    },
  },
]);
```

## Rule Details

Require functions whose first statement is `"use server"` to be async.

React Server Actions must be async even when they do not await anything or
return a promise. This rule checks function declarations, function expressions,
arrow functions, and methods.

Examples of **incorrect** code for this rule:

```jsx
function action() {
  'use server';
  save();
}

<form
  action={() => {
    'use server';
    save();
  }}
>
  Save
</form>;
```

Examples of **correct** code for this rule:

```jsx
async function action() {
  'use server';
  await save();
}

<form
  action={async () => {
    'use server';
    await save();
  }}
>
  Save
</form>;
```

Only the first statement is checked. A preceding statement, including another
directive such as `"use strict"`, prevents a match. Generators and template
literals are ignored. A file-level `"use server"` directive does not cause this
rule to check all exported functions.

The rule offers an editor suggestion to insert `async`; it does not apply an
automatic fix.

## Options

This rule has no options.

## Differences from upstream

- For computed methods, rslint suggests `async [action]() { 'use server'; }`.
  Upstream inserts `async` inside the brackets, which can produce invalid syntax
  or change the method name.
- Constructors, getters, and setters are reported without suggestions because
  they cannot be async. Upstream offers edits that can produce invalid syntax or
  rename an accessor. Move the Server Action into an ordinary async function or
  method instead.

## When Not To Use It

If you are not using React Server Components.

## Original Documentation

This rule follows the upstream commit linked below; it is not included in upstream
release `v7.37.5`.

- [React: use server](https://react.dev/reference/react/use-server)
- [eslint-plugin-react: async-server-action](https://github.com/jsx-eslint/eslint-plugin-react/blob/5d4bf128fb506f604f1bb61bcf76fa8caeea6a1a/docs/rules/async-server-action.md)
- [Source code](https://github.com/jsx-eslint/eslint-plugin-react/blob/5d4bf128fb506f604f1bb61bcf76fa8caeea6a1a/lib/rules/async-server-action.js)
