Next.js Server Actions Demo
Server Actionsを使った実装サンプル
Example 1: Form with Server Action
フォームデータをServer Actionで処理する例
Name
Message
Submit
Example 2: Direct Server Action Call
Server Actionを直接呼び出す例
Text to Reverse
Reverse Text
Server Actionsとは?
Next.js Server Actionsは、サーバー側で実行される非同期関数です。
"use server" ディレクティブで定義
FormDataやその他の引数を受け取れる
クライアント側から直接呼び出し可能
データベースやファイルシステムへの安全なアクセス
型安全性が保たれる