Stop spam on forms in your React or single page app
A startup in Bengaluru builds its marketing site and app in React. The team assumed bots could not handle a JavaScript-heavy site. Yet the contact and sign-up forms get spam daily. The reason is simple: bots skip the React page and post directly to the API endpoint the form calls. Frontend checks alone do nothing. This guide explains how to protect forms in a React or single page app with checks on both sides.
Why SPA forms still get spam
- Bots read the network calls once and then post directly to your API, never loading the React page at all.
- Validation lives only in the browser, so the API accepts whatever a script sends to it.
- A visible CAPTCHA widget hurts the clean design and adds friction on mobile, so the team removed it.
- Spam sign-ups trigger welcome emails and onboarding flows, polluting product analytics and email lists.
Protecting forms in a React app
- Treat the API as the real form. Every form in a SPA is really an API call. Protection must live on the API, not just the React component. Write down each public endpoint that accepts form data: contact, sign-up, waitlist, demo request. These are the targets to protect.
- Add a browser signal and a server check. Use a client SDK in React to collect signals during the form interaction, and send a token with the request. The API then verifies the token with a server-side check. Bots posting directly have no valid token and are stopped.
- Validate on the server. Repeat all validation on the backend: required fields, lengths, email format. Reject unexpected fields. Never trust that the React form did it. This also blocks attempts to inject scripts or SQL through fields the UI does not even show.
- Limit per IP and per user. Set rate limits on each form endpoint. Sign-ups need tighter limits than contact forms. Return a clear error code that your React app can show as a friendly message, so a real user who double-clicks is not confused.
- Monitor sign-up quality. Track how many sign-ups verify their email or complete onboarding. A sudden drop in that rate means junk is getting through. Review blocked requests weekly at first, and adjust thresholds for your own traffic.
How VadiGuard helps
SDK plus verification API
VadiGuard provides a drop-in JavaScript SDK for the browser and a real-time verification API for the server. In a React app, this pairing means bots that skip the page and call your API directly lack a valid result and get stopped.
Clean UI, no puzzles
Genuine users do not see CAPTCHAs, so your React design stays clean. Only high-risk requests are challenged. Your team can keep the form focused on conversion while VadiGuard handles bots, spam and fake emails in the background.
Server middleware and logs
If your API runs on Node.js and Express or Laravel, VadiGuard offers middleware for those. Real-time logs show each blocked request with a risk score, and the AI risk explanation tells developers which signals fired.
A React form is only as safe as the API behind it. Protect the endpoint, pair a browser signal with a server check, validate on the server, rate limit and monitor quality. VadiGuard's SDK and API fit this pattern. Ask the team for a developer demo.
Questions people ask
Is a client-side check enough for React forms?
No. Bots can post directly to your API. Always verify on the server too, using VadiGuard's verification API or middleware.
Does VadiGuard work with Next.js?
VadiGuard lists support for React and Node.js and Express. For Next.js API routes specifically, ask the team to confirm the recommended setup.
Will it affect our Lighthouse or page speed scores?
VadiGuard is a drop-in script designed to be invisible to users. If page speed is critical, ask the team about load behaviour before adding it.
Can we test it before going live?
VadiGuard offers a free start option and demos. Testing on a staging environment first is a good practice.