📝 Submit a React Form to Google Sheets using Google Apps Script and Axios

Search for a command to run...

No comments yet. Be the first to comment.
Claude is incredibly good at reasoning. But reasoning is only as useful as the context available to it. Your architecture might be in GitHub. Your notes might be in Obsidian. Your decisions might be b

Mind maps are an excellent addition to an MCP ecosystem when they help users understand relationships between data, tools, and reasoning. They should complement—not replace—traditional dashboards, tab
Most AI agents today depend heavily on cloud APIs. They're fast, but every request costs money, depends on an internet connection, and sends your data to external providers. Over the weekend, I experi
How I use Fable 5 to research, build, and maintain custom Claude Code plugins, marketplaces, agents, and skills—creating reusable AI tooling that works across every project. 01 · The problem with copy

The way people search is changing. Is your site ready? For the past two decades, SEO (Search Engine Optimization) was the undisputed king of web visibility. Rank on Google's first page and you win tr
Integrating a React form with Google Sheets is a great way to collect user data without setting up a backend server. In this tutorial, we’ll walk through how to create a basic contact form in React and send that data directly to a Google Sheet using Google Apps Script and Axios.
We’ll not use file uploads here to keep things simple and beginner-friendly.
Basic React knowledge
A Google account
Node.js and npm installed
Go to Google Sheets and create a new spreadsheet.
Rename your first row with column headers: Name, Email, Message (or whatever fields you want to collect).
From your Google Sheet, click:
Extensions → Apps ScriptDelete the default code and paste this:
const sheetName = 'Sheet1'
const scriptProp = PropertiesService.getScriptProperties()
function initialSetup () {
const activeSpreadsheet = SpreadsheetApp.getActiveSpreadsheet()
scriptProp.setProperty('key', activeSpreadsheet.getId())
}
function doPost (e) {
const lock = LockService.getScriptLock()
lock.tryLock(10000)
try {
const doc = SpreadsheetApp.openById(scriptProp.getProperty('key'))
const sheet = doc.getSheetByName(sheetName)
const headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0]
const nextRow = sheet.getLastRow() + 1
const newRow = headers.map(function(header) {
console.log(e)
// If header is an array, we need to join the values
if (Array.isArray(e.parameter[header])) {
return e.parameter[header].join(', ')
}
return e.parameters[header].join(",")
})
sheet.getRange(nextRow, 1, 1, newRow.length).setValues([newRow])
return ContentService
.createTextOutput(JSON.stringify({ 'result': 'success', 'row': e.parameters }))
.setMimeType(ContentService.MimeType.JSON)
}
catch (e) {
return ContentService
.createTextOutput(JSON.stringify({ 'result': 'error', 'error': e }))
.setMimeType(ContentService.MimeType.JSON)
}
finally {
lock.releaseLock()
}
}
Click Deploy → Manage deployments
Click + New deployment
Choose Web app
Set:
Execute as: Me (your email)
Who has access: Anyone
Click Deploy
Copy the Web App URL — we’ll use this in our React app.
Create your app (if you haven't):
npx create-react-app react-google-sheet-form
cd react-google-sheet-form
npm install axios
Create a file called RequestForm.js:
import React, { useState } from "react";
import axios from "axios";
function RequestForm() {
const [formData, setFormData] = useState({
Name: "",
Email: "",
Message: "",
});
const [message, setMessage] = useState("");
const handleChange = (e) => {
const { name, value } = e.target;
setFormData({ ...formData, [name]: value });
};
const handleSubmit = async (e) => {
e.preventDefault();
try {
const response = await axios.post(
"YOUR_GOOGLE_APPS_SCRIPT_URL",
formData
);
if (response.data.result === "success") {
setMessage("Form submitted successfully!");
setFormData({ Name: "", Email: "", Message: "" });
} else {
setMessage("Submission failed.");
}
} catch (error) {
setMessage("Error submitting form.");
}
};
return (
<div className="form-container">
<h2>Contact Us</h2>
<form onSubmit={handleSubmit}>
<input
type="text"
name="Name"
placeholder="Your Name"
value={formData.Name}
onChange={handleChange}
required
/>
<input
type="email"
name="Email"
placeholder="Your Email"
value={formData.Email}
onChange={handleChange}
required
/>
<textarea
name="Message"
placeholder="Your Message"
value={formData.Message}
onChange={handleChange}
required
/>
<button type="submit">Submit</button>
</form>
{message && <p>{message}</p>}
</div>
);
}
export default RequestForm;
🔁 Replace
"YOUR_GOOGLE_APPS_SCRIPT_URL"with your actual Google Apps Script deployment URL.
In your App.js:
import React from "react";
import RequestForm from "./RequestForm";
function App() {
return (
<div className="App">
<RequestForm />
</div>
);
}
export default App;
Now run your app:
npm start
Fill out the form and submit. Check your Google Sheet — it should now have a new row with your form data!