Check out our talk at Remix Conf!

Custom response

In this example, a successful submission will render a custom JSON.

import { performMutation } from 'remix-forms'

const schema = z.object({
  firstName: z.string().min(1),
  email: z.string().min(1).email(),
})

const mutation = makeDomainFunction(schema)(async (values) => values)

export const action: ActionFunction = async ({ request }) => {
  const result = await performMutation({ request, schema, mutation })

  if (!result.success) return json(result, 400)

  return json({ customName: result.data.firstName })
}

export default () => <Form schema={schema} />