dev-proPRO
OverviewLộ Trình HọcPhỏng VấnAI System
dev-pro— Thực chiến Frontend React, Next.js & Luyện phỏng vấn
contact@dev-pro.online•Code thật. Phỏng vấn thật.
Seri React Mastery8 Lộ trình · Sandbox
Seri React Mastery
8 tracks
T01
React Core Foundations0/7 hoàn thành
T02
React Hooks Mastery0/5 hoàn thành
T03
React Component Architecture & Forms0/4 hoàn thành
T04
React & Compiler: Modern Path0/4 hoàn thành
T05
Form Engineering: RHF + Zod + Server Actions0/2 hoàn thành
  • Bài học (2)
  • Khi nào dùng Thư viện Form? React Hook Form + Zod Schema16m•intermediate
  • Fullstack Next.js Server Actions & Form Validation15m•advanced
T06
Advanced React Performance Patterns0/4 hoàn thành
T07
Enterprise React Testing & Production Readiness0/5 hoàn thành
T08
Production Capstone: TeamBoard0/1 hoàn thành
Tiến độ React0/32 bài
Form Engineering: RHF + Zod + Server Actions
advanced
15 phút
#Next.js
#Server Actions
#Fullstack Forms

Fullstack Next.js Server Actions & Form Validation

Xây dựng form fullstack với Server Actions, validation, xác thực và phân quyền ở server boundary.

Core Mental Model

Server Action là một entry point có thể được client gọi. Code chạy phía server nhưng input vẫn không đáng tin cậy, nên phải xác thực người dùng, kiểm tra quyền và validate dữ liệu như với API endpoint.

Key Takeaways & Principles

Khai báo "use server" trong Server Action để xử lý data.
Luôn xác thực session, kiểm tra quyền trên đúng tài nguyên, rồi parse FormData và validate lại trên server trước khi ghi Database.
Trả về mảng errors theo field để Client hiển thị lỗi chuẩn xác.