NextJS Server Actions
Data Fetching: Server Actions and Mutations | Next.js
Do use
- when you do a simple API call
Do not use
- When you need HTTP functionality like streaming/websockets
Tips
- Only return what you must
- Code that should only ever execute on the server can be marked with:
import 'server-only';
- Server Actions are serialized if they can and then sent to the client