import { Form, useActionData, useTransition } from "remix"; import { sendEmail } from "~/utils/mailer"; export async function action({ request }) { let body = await request.formData(); let name = body.get('name'); let email = body.get('email'); let message = await sendEmail({ to: email, text: name }); return message; } export default function () { const data = useActionData(); // Understand the page transition, and loading states and action states // If server side code is active, transition will tell you const transition = useTransition(); return (
{data + " - " + transition.state}

Contact Us

{data === 'success' ? (

Your message has been sent!

) : (
{transition.state === 'submitting' ?

Submitting...

: ()}
)}
) }