Understand client-to-server value serialization
mainBy default, remix-hook-form uses double stringification for complex values (arrays, objects, booleans, numbers) when sending data from client to server. This ensures that the server-side utilities can accurately parse the data back into its original types (e.g., a boolean true becomes the string '"true"' so it can be parsed back to true).
Customizing Serialization
Disable double stringification on the client: Set
stringifyAllValues: falsein theuseRemixFormhook. This prevents strings from being double-wrapped.Disable parsing on the server: If you prefer to handle type conversion manually (e.g., using Zod's
coerce), set the third argument ofgetValidatedFormDatatotrue(preserveStringified: true). This tells the utility to return the raw stringified values instead of attempting to parse them back to their original types.
// Client: Disable double stringification
const { handleSubmit, formState, register } = useRemixForm({
mode: "onSubmit",
resolver,
stringifyAllValues: false,
});
// Server: Use raw stringified values (requires manual coercion in schema)
const { errors, data } = await getValidatedFormData<SchemaFormData>(
request,
resolver,
true,
);