@orpc/react package provides utilities for integrating oRPC procedures with React Server Actions and HTML form submissions.
Installation
createFormAction(procedure, options?)
Wraps an oRPC procedure as a React Server Action that accepts a FormData object. The form data is deserialized using bracket notation into the procedure’s expected input shape.
Signature
The oRPC procedure to wrap. Can be a direct procedure or a lazy reference.
Options forwarded to the internal procedure client, such as
context, interceptors, etc.Next.js error handling
createFormAction includes built-in Next.js error handling. When an ORPCError with status 401, 403, or 404 is thrown, it is rethrown with a digest property that Next.js uses to display the correct HTTP error page.
The Next.js digest behavior is handled automatically by the
orpcErrorToNextHttpFallbackInterceptor that createFormAction applies internally. You do not need to configure this manually.FormAction type
FormData object, deserializes it using bracket notation, and calls the underlying procedure. It’s compatible with the HTML <form action={...}> attribute in React.
Bracket notation deserialization
Form data fields are deserialized from bracket notation into nested objects:StandardBracketNotationSerializer from @orpc/openapi-client.
Server Actions with context
When your procedure requires server-side context (e.g. authentication), pass it viaoptions:
parseFormData(formData)
Parse FormData into a plain object using bracket notation. Re-exported from @orpc/openapi-client.
getIssueMessage(issue)
Extracts the human-readable message from a validation issue. Re-exported from @orpc/openapi-client.
