DEV Community

Sh Raj
Sh Raj

Posted on • Originally published at formguard.strivio.world

How I replaced Next.js API Routes for Forms with Cloudflare Workers

For the longest time, whenever I needed a simple "Contact Us" or "Waitlist" form in a Next.js app, my workflow looked like this:

  1. Create a route.ts API endpoint.
  2. Install zod for validation.
  3. Install resend or nodemailer to actually get the email.
  4. Set up an API key, write the HTML email template, handle rate limiting, and write a bunch of boilerplate JSX.

It took hours for what should have been a 5-minute task. Worse, when I started getting spam, I had to figure out how to integrate Google reCAPTCHA, which completely ruined the UX of my site.

The Cloudflare Workers Pivot

I realized that form handling doesn't belong in my edge computing frameworkโ€”it belongs on the absolute edge network itself.

I built FormGuard, an AI-native form backend that runs entirely on Cloudflare Workers.

Here is how you use it:

<form action="https://api.formguard.strivio.world/submit/YOUR_ID" method="POST">
  <input name="email" type="email" required />
  <button type="submit">Join</button>
</form>
Enter fullscreen mode Exit fullscreen mode

That's it. No Next.js API routes, no nodemailer, no React Email templates.

How it stops Spam

Instead of forcing users to click traffic lights, FormGuard uses serverless AI to analyze the payload before it ever hits your inbox. If the payload contains typical spam vectors or bot-like submission patterns, it's silently dropped.

The stack

  • Edge: Cloudflare Workers & Hono
  • Database: Drizzle ORM & Postgres
  • Frontend: Next.js App Router & Tailwind CSS

If you're tired of writing backend code for frontend forms, I'd love for you to check it out. I just launched on Product Hunt today and would appreciate your feedback!

๐Ÿ”— Check out FormGuard on Product Hunt

Top comments (0)