next-safe-action

Typesafe Server Actions in your Next.js 13 app.

README

next-safe-action


next-safe-action is a library that takes full advantage of the latest and greatest Next.js, React and TypeScript features, using Zod, to let you define typesafe Server Actions and execute them inside Client Components.


How does it work?


Like magic. 🪄


Features


- ✅ Pretty simple
- ✅ End-to-end type safety
- ✅ Context based clients (with middlewares)
- ✅ Input validation using Zod
- ✅ Advanced server error handling
- ✅ Optimistic updates

Documentation


Explore the documentation for version 4 of the library on next-safe-action website.

If you are looking for old versions documentation, check out:
- the README_v3 file for version 3.x.x.
- the README_v2 file for version 2.x.x.

Migration guide


Version 4.x.x of the library introduced some breaking changes to the API. Please check out the v3 to v4 migration guide on the website for more information.

Example


You can find a basic working implementation of the library here.

Contributing


If you want to contribute to next-safe-action, the best way is to fork this repository and open a pull request when you're done implementing your feature.

If you found bugs or just want to ask a question, feel free to open an issue.

License


next-safe-action is released under the MIT license.