Blog
Mert Özen's blog posts on software development, backend, frontend, and DevOps.
Forms in React: Controlled Inputs, Form Actions, useActionState, useFormStatus and react-hook-form + zod
React 19's form actions (useActionState, useFormStatus, useOptimistic) are enough for small forms; for forms with line items and nested data, react-hook-form with a zod schema means less code and fewer renders. On the Bookstore order form we show the controlled version rendering on every key, an action resetting the form after a validation error, useOptimistic reverting by itself on failure, and Problem Details errors mapped to fields with focus moved to them.
Building the Bookstore REST API with Express: Routers, Validation with zod, Async Error Handling and Problem Details
A solid REST API with Express separates its layers, validates every request with a zod schema and derives the type from it, turns errors into RFC 9457 Problem Details in one middleware, and keeps money as whole numbers of kuruş instead of floats. With real output: an order total of 1339.1999999999998, a float sum drifting by 5 kuruş over 20 million lines, validation returning six errors in one response, the same Problem Details contract as ASP.NET Core, paging, and z.toJSONSchema.