बिना बैकएंड ईमेल भेजने वाला React संपर्क फ़ॉर्म

Formgong team ·

FormData को fetch से Formgong एंडपॉइंट पर भेजें और अपनी सार्वजनिक एक्सेस कुंजी चिपकाएँ। Formgong स्पैम छानता है और लीड को ईमेल तथा Telegram पर पहुँचाता है। Telegram तुरंत आता है। मुफ़्त प्लान पर ईमेल रोज़ का डाइजेस्ट है। आप सर्वर, SMTP या गुप्त कुंजी नहीं चलाते। नीचे का कंपोनेंट चिपका दें।

एक फ़ॉर्म बनाएँ, एक्सेस कुंजी कॉपी करें, और कंपोनेंट में fk_your_access_key बदल दें। कुंजी सार्वजनिक है। इसकी जगह यही फ़ाइल है।

Vite या Create React App
import { useState } from "react";

// अपनी कुंजी चिपकाएँ: fk_your_access_key को अपने Formgong फ़ॉर्म की कुंजी से बदलें।
const ACCESS_KEY = "fk_your_access_key";

export default function ContactForm() {
  const [status, setStatus] = useState("idle");
  const [notice, setNotice] = useState("");

  async function onSubmit(event) {
    event.preventDefault();
    const form = event.currentTarget;
    if (!(form instanceof HTMLFormElement) || !form.reportValidity()) return;
    const body = new FormData(form);
    body.set("access_key", ACCESS_KEY);
    body.set("_lang", "hi");
    setStatus("sending");
    setNotice("");
    try {
      const response = await fetch("https://formgong.com/submit", {
        method: "POST",
        headers: { Accept: "application/json" },
        body,
      });
      const result = await response.json();
      if (!response.ok || !result.success) {
        setStatus("error");
        setNotice(result.message || "भेजा नहीं जा सका। कृपया फिर से कोशिश करें।");
        return;
      }
      form.reset();
      setStatus("success");
      setNotice(result.message || "भेज दिया गया। धन्यवाद!");
    } catch {
      setStatus("error");
      setNotice("कनेक्शन विफल। कृपया फिर से कोशिश करें।");
    }
  }

  const sending = status === "sending";
  return (
    <form onSubmit={onSubmit}>
      <label>{"नाम"} <input name="name" autoComplete="name" placeholder={"आपका नाम"} required /></label>
      <label>{"ईमेल"} <input name="email" type="email" autoComplete="email" placeholder={"you@example.com"} required /></label>
      <label>{"संदेश"} <textarea name="message" placeholder={"हम आपकी कैसे मदद कर सकते हैं?"} required /></label>
      <div aria-hidden="true" style={{ position: "absolute", insetInlineStart: 0, top: 0, width: 1, height: 1, overflow: "hidden", clipPath: "inset(50%)" }}>
        <input name="botcheck" tabIndex={-1} autoComplete="off" />
      </div>
      <button type="submit" disabled={sending}>{sending ? "भेजा जा रहा है…" : "भेजें"}</button>
      <p role={status === "error" ? "alert" : "status"}>{notice}</p>
    </form>
  );
}

React के और सेटअप

Vite या Create React App

ऊपर वाला कंपोनेंट यही सेटअप है। इसे src/ContactForm.jsx के रूप में सहेजें और App से दिखाएँ। अतिरिक्त पैकेज नहीं।

Vite या Create React App
// src/App.jsx — Vite or Create React App
import ContactForm from "./ContactForm";

export default function App() {
  return <ContactForm />;
}
Next.js App Router

फ़ाइल के शुरू में क्लाइंट डायरेक्टिव जोड़ें। फ़ॉर्म दिखाने वाला पेज सर्वर कंपोनेंट रह सकता है।

Next.js App Router
"use client";

import { useState } from "react";

// अपनी कुंजी चिपकाएँ: fk_your_access_key को अपने Formgong फ़ॉर्म की कुंजी से बदलें।
const ACCESS_KEY = "fk_your_access_key";

export default function ContactForm() {
  const [status, setStatus] = useState("idle");
  const [notice, setNotice] = useState("");

  async function onSubmit(event) {
    event.preventDefault();
    const form = event.currentTarget;
    if (!(form instanceof HTMLFormElement) || !form.reportValidity()) return;
    const body = new FormData(form);
    body.set("access_key", ACCESS_KEY);
    body.set("_lang", "hi");
    setStatus("sending");
    setNotice("");
    try {
      const response = await fetch("https://formgong.com/submit", {
        method: "POST",
        headers: { Accept: "application/json" },
        body,
      });
      const result = await response.json();
      if (!response.ok || !result.success) {
        setStatus("error");
        setNotice(result.message || "भेजा नहीं जा सका। कृपया फिर से कोशिश करें।");
        return;
      }
      form.reset();
      setStatus("success");
      setNotice(result.message || "भेज दिया गया। धन्यवाद!");
    } catch {
      setStatus("error");
      setNotice("कनेक्शन विफल। कृपया फिर से कोशिश करें।");
    }
  }

  const sending = status === "sending";
  return (
    <form onSubmit={onSubmit}>
      <label>{"नाम"} <input name="name" autoComplete="name" placeholder={"आपका नाम"} required /></label>
      <label>{"ईमेल"} <input name="email" type="email" autoComplete="email" placeholder={"you@example.com"} required /></label>
      <label>{"संदेश"} <textarea name="message" placeholder={"हम आपकी कैसे मदद कर सकते हैं?"} required /></label>
      <div aria-hidden="true" style={{ position: "absolute", insetInlineStart: 0, top: 0, width: 1, height: 1, overflow: "hidden", clipPath: "inset(50%)" }}>
        <input name="botcheck" tabIndex={-1} autoComplete="off" />
      </div>
      <button type="submit" disabled={sending}>{sending ? "भेजा जा रहा है…" : "भेजें"}</button>
      <p role={status === "error" ? "alert" : "status"}>{notice}</p>
    </form>
  );
}

// app/contact/page.jsx — this file can stay a Server Component.
import ContactForm from "./ContactForm";

export default function Page() {
  return <ContactForm />;
}
React Hook Form

react-hook-form इंस्टॉल करें। वैलिडेशन वहीं रखें। सबमिट हैंडलर फिर भी FormData को Formgong पर पोस्ट करता है।

React Hook Form
import { useState } from "react";
import { useForm } from "react-hook-form";

// अपनी कुंजी चिपकाएँ: fk_your_access_key को अपने Formgong फ़ॉर्म की कुंजी से बदलें।
const ACCESS_KEY = "fk_your_access_key";

export default function ContactForm() {
  const { register, handleSubmit, reset, formState: { errors, isSubmitting } } = useForm();
  const [notice, setNotice] = useState("");
  const [failed, setFailed] = useState(false);

  async function onSubmit(values) {
    const body = new FormData();
    body.set("access_key", ACCESS_KEY);
    body.set("_lang", "hi");
    body.set("name", values.name);
    body.set("email", values.email);
    body.set("message", values.message);
    body.set("botcheck", values.botcheck || "");
    setFailed(false);
    setNotice("");
    try {
      const response = await fetch("https://formgong.com/submit", {
        method: "POST",
        headers: { Accept: "application/json" },
        body,
      });
      const result = await response.json();
      if (!response.ok || !result.success) {
        setFailed(true);
        setNotice(result.message || "भेजा नहीं जा सका। कृपया फिर से कोशिश करें।");
        return;
      }
      reset();
      setNotice(result.message || "भेज दिया गया। धन्यवाद!");
    } catch {
      setFailed(true);
      setNotice("कनेक्शन विफल। कृपया फिर से कोशिश करें।");
    }
  }

  return (
    <form onSubmit={handleSubmit(onSubmit)}>
      <label>{"नाम" <input {...register("name", { required: "ज़रूरी" })} aria-invalid={errors.name ? true : undefined} autoComplete="name" /></label>
      {errors.name && <span>{errors.name.message}</span>}
      <label>{"ईमेल" <input type="email" {...register("email", { required: "ज़रूरी" })} aria-invalid={errors.email ? true : undefined} autoComplete="email" /></label>
      {errors.email && <span>{errors.email.message}</span>}
      <label>{"संदेश" <textarea {...register("message", { required: "ज़रूरी" })} aria-invalid={errors.message ? true : undefined} /></label>
      {errors.message && <span>{errors.message.message}</span>}
      <div aria-hidden="true" style={{ position: "absolute", insetInlineStart: 0, top: 0, width: 1, height: 1, overflow: "hidden", clipPath: "inset(50%)" }}>
        <input {...register("botcheck")} tabIndex={-1} autoComplete="off" />
      </div>
      <button type="submit" disabled={isSubmitting}>{isSubmitting ? "भेजा जा रहा है…" : "भेजें"}</button>
      {failed ? <p role="alert">{notice}</p> : <p role="status">{notice}</p>}
    </form>
  );
}
TypeScript

वही कंपोनेंट, स्टेटस और JSON नतीजे के लिए टाइप के साथ। इसे ContactForm.tsx के रूप में सहेजें।

TypeScript
import { useState, type FormEvent } from "react";

// अपनी कुंजी चिपकाएँ: fk_your_access_key को अपने Formgong फ़ॉर्म की कुंजी से बदलें।
const ACCESS_KEY = "fk_your_access_key";

type Status = "idle" | "sending" | "success" | "error";
type SubmitResult = { success?: boolean; message?: string };

export default function ContactForm() {
  const [status, setStatus] = useState<Status>("idle");
  const [notice, setNotice] = useState("");

  async function onSubmit(event: FormEvent<HTMLFormElement>) {
    event.preventDefault();
    const form = event.currentTarget;
    if (!form.reportValidity()) return;
    const body = new FormData(form);
    body.set("access_key", ACCESS_KEY);
    body.set("_lang", "hi");
    setStatus("sending");
    setNotice("");
    try {
      const response = await fetch("https://formgong.com/submit", {
        method: "POST",
        headers: { Accept: "application/json" },
        body,
      });
      const result = (await response.json()) as SubmitResult;
      if (!response.ok || !result.success) {
        setStatus("error");
        setNotice(result.message || "भेजा नहीं जा सका। कृपया फिर से कोशिश करें।");
        return;
      }
      form.reset();
      setStatus("success");
      setNotice(result.message || "भेज दिया गया। धन्यवाद!");
    } catch {
      setStatus("error");
      setNotice("कनेक्शन विफल। कृपया फिर से कोशिश करें।");
    }
  }

  const sending = status === "sending";
  return (
    <form onSubmit={onSubmit}>
      <label>{"नाम"} <input name="name" autoComplete="name" placeholder={"आपका नाम"} required /></label>
      <label>{"ईमेल"} <input name="email" type="email" autoComplete="email" placeholder={"you@example.com"} required /></label>
      <label>{"संदेश"} <textarea name="message" placeholder={"हम आपकी कैसे मदद कर सकते हैं?"} required /></label>
      <div aria-hidden="true" style={{ position: "absolute", insetInlineStart: 0, top: 0, width: 1, height: 1, overflow: "hidden", clipPath: "inset(50%)" }}>
        <input name="botcheck" tabIndex={-1} autoComplete="off" />
      </div>
      <button type="submit" disabled={sending}>{sending ? "भेजा जा रहा है…" : "भेजें"}</button>
      <p role={status === "error" ? "alert" : "status"}>{notice}</p>
    </form>
  );
}

GitHub पर तैयार React कंपोनेंट: github.com/formgong/react-contact-form. MIT लाइसेंस: “Use this template” पर क्लिक करें या फ़ाइलें कॉपी करें।

React पैकेज: npm install @formgong/react (npm: @formgong/react)

मौजूदा प्रोजेक्ट में जोड़ें: npx formgong init (npm: formgong)

React में फ़ॉर्म कैसे काम करते हैं

React फ़ॉर्म बनाता है। मेल नहीं भेजता। Vite और Create React App स्थिर फ़ाइलें देते हैं, इसलिए ब्राउज़र को ऐसा URL चाहिए जो POST स्वीकार करे।

वह URL Formgong है। कंपोनेंट FormData को fetch से /submit पर भेजता है। साथ में सार्वजनिक access_key, _lang और खाली botcheck फ़ील्ड जाती है। Formgong स्पैम छानता है और लीड पहुँचाता है।

यहाँ क्या अलग है

  • Telegram मुफ़्त प्लान पर भी तुरंत आता है। ईमेल भी शामिल है, एक पाने वाले के लिए रोज़ का डाइजेस्ट।
  • सबमिशन EU में, EU अधिकार वाले Cloudflare D1 पर रखे जाते हैं।
  • स्पैम फ़िल्टर को CAPTCHA या कुकीज़ नहीं चाहिए। हनीपॉट हमेशा चालू रहता है। Turnstile वैकल्पिक है।
  • कंपोनेंट की एक्सेस कुंजी सार्वजनिक है। आप SMTP पासवर्ड या निजी API कुंजी बंडल में नहीं रखते।
  • त्रुटि पाठ और धन्यवाद पेज विज़िटर की भाषा का अनुसरण कर सकते हैं। भाषाएँ 12 हैं।

EmailJS या अपनी API रूट क्यों नहीं?

EmailJS या अपनी API रूट क्यों नहीं?
EmailJSआपका API रूटFormgong
आप क्या जोड़ते हैंएक npm पैकेज, service id, template id और एक सार्वजनिक कुंजी।एक सर्वरलेस फ़ंक्शन और Nodemailer जैसा SMTP क्लाइंट।इस पेज के कंपोनेंट में एक सार्वजनिक एक्सेस कुंजी।
ईमेलआपके टेम्पलेट से तुरंत मेल। मुफ़्त प्लान महीने के 200 अनुरोध और 2 टेम्पलेट है।तुरंत मेल, जब आपका प्रोवाइडर संदेश स्वीकार करे।मुफ़्त प्लान पर रोज़ का डाइजेस्ट। हर लीड का ईमेल Pro और Business पर है।
Telegramयह EmailJS का हिस्सा नहीं है। सेवा ईमेल भेजती है।केवल अगर आप वह कॉल खुद लिखें।मुफ़्त प्लान पर ही तुरंत डिलीवरी।
ब्राउज़र में कुंजियाँसार्वजनिक कुंजी सार्वजनिक ही रहनी चाहिए। निजी कुंजी सर्वर पर रखें।SMTP पासवर्ड होस्ट के वातावरण में रहता है। यही इस रास्ते की ताकत है।एक्सेस कुंजी सार्वजनिक है। कोई SMTP रहस्य नहीं।
स्पैमसीमाएँ आप EmailJS डैशबोर्ड में रखते हैं। 2024 का Webtips ट्यूटोरियल कुछ नहीं जोड़ता।फ़िल्टर आप बनाते हैं।हनीपॉट हमेशा चालू है। कुकीज़ नहीं। CAPTCHA ज़रूरी नहीं।
मुफ़्त कोटामहीने में 200 अनुरोध, फिर अतिरिक्त अनुरोध गिर जाते हैं।आपके होस्ट का मुफ़्त स्तर, और आपके मेल प्रोवाइडर की सीमा।महीने में 300 सबमिशन।
डेटा कहाँ रहता हैEmailJS इतिहास अपने सर्वरों पर रखता है। मुफ़्त प्लान 7 दिन रखता है। कीमत पेज नहीं कहता कि केवल EU।जहाँ आपका होस्ट और मेल प्रोवाइडर उसे रखें।EU में, Cloudflare D1 पर।

EmailJS चुनें जब मेल आपके इनबॉक्स से, आपके टेम्पलेट से, भेजते ही निकलना हो।

Vercel या Netlify फ़ंक्शन चुनें जब सबमिट आपके डेटाबेस को अपडेट करे या जाँचे कि विज़िटर लॉग इन है।

संपर्क फ़ॉर्म के लिए Formgong चुनें। मुफ़्त प्लान पर Telegram तुरंत है। उस प्लान पर ईमेल रोज़ का डाइजेस्ट है। SMTP रहस्य नहीं रखते।

EmailJS के आँकड़े 6 अक्टूबर 2026 के कीमत पेज से हैं। API रूट वाला कॉलम Vercel या Netlify फ़ंक्शन और SMTP है, किसी एक सेवा की कीमत सूची नहीं।

React में सेटअप

  1. Formgong में फ़ॉर्म बनाएँ और एक्सेस कुंजी कॉपी करें। वह fk_your_access_key जैसी दिखती है।
  2. ऊपर का कंपोनेंट ऐप में चिपकाएँ और वह कुंजी बदल दें।
  3. कंपोनेंट दिखाएँ, साइट खोलें और अपने आप को एक टेस्ट भेजें।
  4. Formgong में फ़ॉर्म खोलें और फ़ोन अलर्ट चाहिए तो Telegram जोड़ें।

सवाल और जवाब

क्या React संपर्क फ़ॉर्म के लिए बैकएंड चाहिए?

नहीं। FormData को fetch से Formgong पर भेजें। API रूट, Nodemailer या SMTP नहीं जोड़ते।

Nodemailer या SMTP के बिना React से ईमेल कैसे भेजें?

इस पेज का कंपोनेंट उपयोग करें। Formgong POST स्वीकार करता है और स्पैम छानता है। Telegram को लीड तुरंत मिलती है। मुफ़्त प्लान पर ईमेल रोज़ का डाइजेस्ट है। Pro और Business हर सबमिशन पर ईमेल करते हैं।

क्या कुंजी को क्लाइंट कोड में रखना सुरक्षित है?

हाँ। access_key सार्वजनिक है। वह केवल यह फ़ॉर्म भेज सकती है। इनबॉक्स नहीं पढ़ सकती। Pro पर अनुमत डोमेन सीमित कर सकते हैं। SMTP पासवर्ड बंडल में न रखें।

React फ़ॉर्म पर स्पैम कैसे रोकें?

botcheck खाली छोड़ें। Formgong स्पैम को बिना कुकीज़ और बिना ज़रूरी CAPTCHA के आँकता है। बाद में पहेली चाहिए तो Turnstile वैकल्पिक है।

क्या यह Next.js के साथ चलता है?

हाँ। App Router में फ़ाइल के शुरू में "use client" जोड़ें। कंपोनेंट वही रहता है। इस पेज का Next.js वैरिएंट फ़ाइल दिखाता है।

मुफ़्त शुरू करें