timoclsn / next-safe-action

Type safe and validated Server Actions in your Next.js (App Router) project.

Home Page:https://next-safe-action.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 5 of the library on the next-safe-action website. ✨

If you are looking for old versions documentation, check out:

Next.js >= 14 vs 13

Server Actions are now a stable feature in React. For this reason, there were some internal breaking changes to the API, and so a new version of the library is required to prevent backward compatibility issues.

You can continue to use next-safe-action version 4 for your Next.js 13 app:

# For Next.js 13 apps
npm i next-safe-action@v4


# For Next.js >= 14 apps
npm i next-safe-action

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.


Version 5.x.x of the library is required for Next.js >= 14 applications. Please check out the v4 to v5 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.

About

Type safe and validated Server Actions in your Next.js (App Router) project.

https://next-safe-action.dev

License:MIT License


Languages

Language:TypeScript 81.4%Language:JavaScript 11.9%Language:CSS 6.4%Language:Shell 0.4%