Skip to content
Lazyform
Docs menu

Frameworks and builders

Remix

Add a Lazyform contact form to Remix or React Router v7, posting from the browser or through a route action.

Remix is now React Router v7 (framework mode). The examples below use React Router v7 imports; on Remix v2, import the same hooks from @remix-run/react instead. You can post straight from the browser, or use a route action that posts from your server.

Before you start

Get an access key: type your email on the homepage for an instant key, or sign in and create a form. Replace YOUR_ACCESS_KEY with your key (it starts with lf_).

The minimal form

A plain <form> (not Remix's <Form>) posts directly to Lazyform and shows a thank-you page.

app/routes/contact.tsx
export default function Contact() {
  return (
    <form action="https://lazyform-api.xvelopers.com/submit" method="post">
      <input type="hidden" name="access_key" value="YOUR_ACCESS_KEY" />
      <input type="text" name="name" placeholder="Name" required />
      <input type="email" name="email" placeholder="Email" required />
      <textarea name="message" placeholder="Message" required />
      <input type="checkbox" name="botcheck" className="hidden" style={{ display: 'none' }} tabIndex={-1} autoComplete="off" />
      <button type="submit">Send</button>
    </form>
  );
}

From the browser or through an action

tsx
// app/routes/contact.tsx
import { useState, type FormEvent } from 'react';

export default function Contact() {
  const [status, setStatus] = useState<'idle' | 'sending' | 'success' | 'error'>('idle');
  const [error, setError] = useState('');

  async function handleSubmit(event: FormEvent<HTMLFormElement>) {
    event.preventDefault();
    const form = event.currentTarget;
    setStatus('sending');
    try {
      const response = await fetch('https://lazyform-api.xvelopers.com/submit', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
        body: JSON.stringify(Object.fromEntries(new FormData(form))),
      });
      const result = await response.json();
      if (result.success) {
        setStatus('success');
      } else {
        setStatus('error');
        setError(result.error?.message ?? 'Something went wrong.');
      }
    } catch {
      setStatus('error');
      setError('Network error. Please try again.');
    }
  }

  if (status === 'success') return <p>Thanks! Your message has been sent.</p>;

  return (
    <form onSubmit={handleSubmit}>
      <input type="hidden" name="access_key" value="YOUR_ACCESS_KEY" />
      <input type="text" name="name" placeholder="Name" required />
      <input type="email" name="email" placeholder="Email" required />
      <textarea name="message" placeholder="Message" required />
      <input type="checkbox" name="botcheck" className="hidden" style={{ display: 'none' }} tabIndex={-1} autoComplete="off" />
      <button type="submit" disabled={status === 'sending'}>{status === 'sending' ? 'Sending...' : 'Send'}</button>
      {status === 'error' && <p role="alert">{error}</p>}
    </form>
  );
}

Tips

  • <form> vs <Form>. Use a plain <form> when posting to Lazyform directly. Remix's <Form> submits to your own route action.
  • Which one to pick. The browser version keeps allowed websites and per-visitor rate limiting working as designed. The action posts from your server, which sends no Origin from your site, so don't combine it with allowed websites.
  • Environment variables. Keep LAZYFORM_KEY in your server environment for the action variant.

Where to go next