OSS TanbouSign in with GitHub

add end-to-end type safety, validation, and middleware to Next.js Server Actions

About these scores

OSS scale score is an unbounded metric that log-compresses and weights Stars, Watchers, Forks, and Contributors. Discovery score is the current OSS scale score minus the score at discovery. Update pace is commits in the last 30 days, growth momentum is the OSS scale score difference within the recent observation window, and OSS health is a 0–100 rating based on available recency, Community Health, and release data.

Stars
3,076
Primary language
TypeScript
License
MIT
Repository last updated
Sep 30, 2026
On this page

Overview

next-safe-action is a library for defining and executing Next.js Server Actions with type safety and validation. It combines input and output validation, middleware, server error handling, form actions, and optimistic updates while preserving types across the client-to-server boundary.

Features and best fit

Based on official documentation; not hands-on tested · Content checked:

Key features

Connect Server Action inputs and outputs through validation schemas and TypeScript types

Action definitions can validate inputs and preserve client/server types, with support for multiple validation libraries including Zod.

Sources: [1]

Centralize action lifecycle behavior with middleware, error handling, and React hooks

The middleware system, server-error handling, Form Actions, and optimistic-action hooks help centralize authentication, logging, validation errors, and UI lifecycle behavior.

Sources: [1]

Best fit

Fits Next.js App Router applications that use Server Actions as the mutation boundary

It is useful when applications want mutations centered on Server Actions rather than separate REST endpoints while strengthening validation and end-to-end type safety.

Sources: [1][2]

Before adoption

Target Next.js 14+ and React 18.2+ and retest integration across framework upgrades

Version 8.7.3 requires Node 18.17+, declares Next.js 14+ and React/React DOM 18.2+ as peer requirements, and depends on framework Server Action behavior, so Next.js upgrades should include integration tests.

Sources: [2]

Test client lifecycle callbacks such as redirect and navigation behavior across updates

Version 8.7.3 fixes duplicate onNavigation and onSettled callbacks around redirects in action hooks. Test navigation and optimistic-state behavior in addition to server-side success and error results.

Sources: [3]

Official sources

  1. [1]next-safe-action 8.7.3 README(2026-10-06)
  2. [2]next-safe-action 8.7.3 package metadata(2026-10-06)
  3. [3]next-safe-action 8.7.3 release(2026-10-06)
  4. [4]next-safe-action MIT license(2026-10-06)
Supplemental curator note

It fits App Router applications that use Server Actions as mutation boundaries. Review validation schemas, middleware responsibilities, framework versions, and redirect/navigation lifecycle behavior across upgrades.

Try it in 3 steps

  1. 1

    Get the source

    git clone --depth 1 https://github.com/next-safe-action/next-safe-action.git
  2. 2

    Enter the repository

    cd next-safe-action
  3. 3

    Check the official steps

    Continue with the commands in the README Installation, Quick Start, or Getting Started section.

    find . -maxdepth 1 -iname 'README*' -exec sed -n '1,220p' {} \; -quit
Check the official README

Growth

Growth trends · Last 30 days

3,076 Stars

Trend data is still being collected.

Development activity

Last 90 days · weekly

Commits (last 30 days)
4
Open PRs
1

Development activity is still being collected.

Built with

Categories and tags

GitHub data

GitHub dataView detailed GitHub data

GitHub Topics

  • actions
  • app-dir
  • mutations
  • next
  • nextjs
  • react
  • rsc
  • server-components
  • typesafe
  • typescript
  • react-server-components
  • react-actions
Stars
3,076
Forks
48
Watchers
6
Open issues
5
Contributors
26
Owner type
Organization
Primary language
TypeScript
License
MIT
Repository last updated
Sep 30, 2026
Write a related article

Share a guide or use case for this OSS in Markdown. Articles are published after administrator approval.

Report incorrect information

Tell us if any listing information is incorrect or outdated.

After reading this page, do you know what to do next?