Server Actions란
Server Actions는 서버에서 실행되는 비동기 함수로, 클라이언트에서 직접 호출할 수 있습니다. API 라우트 없이 폼 제출, 데이터 변경이 가능합니다.
"use server"
export async function createPost(formData: FormData) {
const title = formData.get("title") as string;
await db.post.create({ data: { title } });
revalidatePath("/posts");
}useFormStatus
로딩 상태를 자동으로 추적할 수 있습니다.
댓글 0