# Error: Server Action payload exceeds the maximum size limit (4MB).

- **ID:** `nextjs/server-action-body-size-exceeded`
- **Domain:** nextjs
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Server Actions have a default body size limit of 4MB; uploading large files or sending large FormData objects triggers this error.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| next@14.0.0 | active | — | — |
| next@14.1.0 | active | — | — |
| next@15.0.0 | active | — | — |

## Workarounds

1. **Increase the body size limit for the specific server action route in next.config.js:

export default {
  experimental: {
    serverActions: {
      bodySizeLimit: '10mb',
    },
  },
};

Or set it per action using the config export: export const config = { api: { bodyParser: { sizeLimit: '10mb' } } };** (85% success)
   ```
   Increase the body size limit for the specific server action route in next.config.js:

export default {
  experimental: {
    serverActions: {
      bodySizeLimit: '10mb',
    },
  },
};

Or set it per action using the config export: export const config = { api: { bodyParser: { sizeLimit: '10mb' } } };
   ```
2. **Upload large files directly to a cloud storage service (e.g., S3) using a presigned URL, and only send the file reference to the server action.** (90% success)
   ```
   Upload large files directly to a cloud storage service (e.g., S3) using a presigned URL, and only send the file reference to the server action.
   ```
3. **Implement chunked uploads client-side, sending parts of the file as separate server actions, then reassemble on the server.** (75% success)
   ```
   Implement chunked uploads client-side, sending parts of the file as separate server actions, then reassemble on the server.
   ```

## Dead Ends

- **** — This works but may not be allowed in some hosting environments; also, it's a security risk if not carefully scoped. (40% fail)
- **** — Server Actions expect FormData; compression breaks the form structure unless handled server-side. (70% fail)
- **** — This adds complexity and may cause race conditions or partial failures without proper transaction handling. (60% fail)
