OSS探訪GitHubでログイン

Next.js Server Actionsへend-to-end型安全・validation・middlewareを追加する

スコアの見方

OSS規模スコアはStars・Watchers・Forks・Contributorsを対数圧縮して重み付けした現在の規模指標(上限なし)です。発掘スコアは現在のOSS規模スコアから発掘時点のOSS規模スコアを引いた値、更新ペースは直近30日Commit数、成長モメンタムは直近の観測期間におけるOSS規模スコア差、OSS健全度は取得できた更新状況・Community Health・Releaseの0〜100評価です。

Stars
3,076
主要言語
TypeScript
ライセンス
MIT
リポジトリ最終更新
2026/09/30
ページ内ナビ

概要

next-safe-actionはNext.js Server Actionsをtype-safeかつvalidatedに定義・実行するためのlibraryです。input/output validation、middleware、server error handling、form action、optimistic update等を組み合わせ、clientからserver actionまで型情報をつなげます。

特徴と向いている用途

公式資料に基づく紹介・実機未検証 · 内容確認日:

主な特徴

Server Actionのinput/outputをvalidation schemaと型でつなぐ

action definitionにvalidationを組み込み、clientから渡すinputとserver側resultをTypeScriptで追跡できます。Zod等を含む複数validation libraryを利用できます。

出典:[1]

middleware・error handling・React hooksでaction lifecycleを共通化する

middleware system、advanced server error handling、Form Actions、optimistic update向けhooks等を使い、認証・logging・validation errorの処理をactionごとにばらけさせず共通化できます。

出典:[1]

向いている用途

Next.js App Routerでmutation処理をServer Actions中心に設計する場合に向く

REST endpointを別に作らずServer Actionsをmutation boundaryとして使いながら、client/server間の型安全とvalidationを強化したいNext.js applicationに適します。

出典:[1][2]

導入前の確認

Next.js 14以上・React 18.2以上を前提にし、framework upgradeと合わせて検証する

v8.7.3 package metadataはNode 18.17以上、Next.js 14以上、React/React DOM 18.2以上をpeer requirementとしています。Server Actionsのframework behaviorに依存するためNext.js upgrade時はintegration testが必要です。

出典:[2]

redirect/navigation callback等のclient lifecycleもversion更新時に確認する

v8.7.3はuseAction等でredirect時にonNavigationとonSettledが二重発火する問題を修正しました。hook-based UI behaviorはaction成功だけでなくnavigation/optimistic stateも含めてtestしてください。

出典:[3]

参考にした公式資料

  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)
編集部からの補足

App RouterでServer Actionsをmutation boundaryとして使う場合に向きます。validation schema、middleware責務、framework version、redirect/navigation lifecycleをupgrade時に確認してください。

3ステップで試す

  1. 1

    ソースを取得

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

    リポジトリへ移動

    cd next-safe-action
  3. 3

    公式手順を確認

    READMEのInstallation / Quick Start / Getting Startedにある公式コマンドを続けて実行してください。

    find . -maxdepth 1 -iname 'README*' -exec sed -n '1,220p' {} \; -quit
公式READMEで確認

成長

成長の推移 · 直近30日

3,076 Stars

推移データを蓄積中です。

開発アクティビティ

直近90日・週次

Commit(直近30日)
4
Open PR
1

開発アクティビティを蓄積中です。

Built with

カテゴリとタグ

GitHubデータ

GitHubのデータGitHubの詳細データを見る

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
所有者種別
Organization
主要言語
TypeScript
ライセンス
MIT
リポジトリ最終更新
2026/09/30

このOSSの使い方や活用事例をMarkdownで投稿できます。管理者が承認した後に公開されます。

情報の誤りを報告

掲載内容に誤りや古い情報があればお知らせください。

このページを読んで、次に何をすればよいか分かりましたか?
next-safe-actionとは?型安全なNext.js Server Actions | OSS探訪