Skip to content
AI-powered appsNewChat, vision, voice, generationBookings & schedulingAppointments that book themselvesShops & sellingA storefront in every pocketClient & businessRun the operation from one placeCommunities & clubsA home that is not a group chat
Health & wellnessHabits, tracking and calmGames2D, 3D and multiplayerPersonal & toolsThe tool you wish existedInternal toolsThe tool ops never had time for
See all use cases
ArcadeNewPricingSecurity
EngineThe game engine and World EditorHow it worksFrom one sentence to a live productDocsGuides for building and publishingBlogStories, guides and newsChangelogWhat shipped latelyStatusUptime of every serviceSupportGet help from the team
AI-powered appsBookings & schedulingShops & sellingClient & businessCommunities & clubsHealth & wellnessGamesPersonal & toolsInternal tools
See all use cases
ArcadeNewPricingSecurity
EngineHow it worksDocsBlogChangelogStatusSupport
Language
Blog
IntegrationsNovember 22, 20265 min read

Connect your app to Google Sheets

Google Sheets makes a great admin panel and a poor database. Here is how to connect one to your app so each does what it is good at.

Startbase Team
Editorial ink illustration of an open ledger book with a brass pipe running into a filing cabinet, the pipe valve in ember orange

Key takeaways

  • Use a Google Cloud service account, share the sheet with its email address, and keep its JSON key in Backend → Secrets.
  • For reads, sync the sheet into your own database on a schedule instead of calling the Sheets API on every page view.
  • Map columns by header name, not position, and validate every row: people will rename, reorder and type into your sheet.

You connect an app to Google Sheets through the Google Sheets API, called from a server function that signs in as a Google Cloud service account. You create the service account, share the specific spreadsheet with its email address, store its key as a secret, and let the function read ranges or append rows. For anything visitors load, copy the sheet into your own database on a schedule. The sheet stays the place where a human edits; the database is what the app reads.

Three ways to connect, and when each fits

  • Published CSV (read-only, no key). File → Share → Publish to web gives a CSV link. Simple, but the data becomes public to anyone with the link, and Google caches it, so edits can take minutes to show. Fine for a public price list, wrong for anything private.
  • Sheets API with a service account (read and write). The approach this article follows. Private, fast, and works without any user signing in to Google.
  • Per-user OAuth. Needed only when each of your users connects their own sheet. It means a Google consent screen, refresh tokens and possibly Google's app verification. Most apps do not need it.

If your real goal is to replace the spreadsheet with an app, read turning a spreadsheet into an app first. Connecting is for when the sheet stays in the workflow: an operations team that lives in Sheets, a finance export, a client who refuses to log into anything else.

What you need

  1. 01A Google Cloud project with the Google Sheets API enabled. A personal Google account works; a Workspace account may need an admin to allow service account keys.
  2. 02A service account and a JSON key. The key file contains a private key. Paste the whole JSON into Backend → Secrets as one secret, for example `GOOGLE_SERVICE_ACCOUNT_JSON`. Never commit the file or paste it into chat.
  3. 03The sheet shared with the service account's email (it looks like `name@project.iam.gserviceaccount.com`), as Viewer for read-only or Editor for writes.
  4. 04The spreadsheet ID from the URL, stored as a plain setting or secret like `SHEET_ID`.

Reading: sync, do not proxy

Say a bakery keeps its menu in a sheet with columns `Item`, `Price`, `Category`, `Available`, `Allergens`. The tempting design is a function that reads the sheet every time the menu page loads. Do not. The Sheets API has per-minute request quotas per project and per user, each read takes noticeable time, and a traffic spike turns into quota errors and an empty menu.

Instead, a scheduled job runs a `sync-menu` function every 10 minutes (a starting value: tune it to how fresh the data must be). It reads `Menu!A1:E500`, maps each row by header name, validates it, and upserts into a `menu_items` table keyed by a stable id. Rows that fail validation go into a `sync_errors` table with the row number and reason, so the owner sees 'Row 14: price "four" is not a number' instead of a silently missing croissant. Add a 'Sync now' button for the owner that calls the same function.

Tip

Add an `id` column to the sheet and never reuse values. Matching on the item name breaks the day someone fixes a typo, and the app treats it as a delete plus a new item.

Writing: append on events

The other direction is usually 'put every order (or signup, or lead) into a sheet so the team can see it'. The order is saved to your database first, always. Then the app calls an `append-order-row` function with the order id. The function loads the order, formats it as one row (`2026-11-22 09:14`, `#1042`, `Ana P.`, `3 items`, `24.50`) and calls the append endpoint with `valueInputOption: USER_ENTERED` so dates and numbers display properly.

If the append fails (quota, a renamed tab, a revoked share), the order still exists. Mark it `sheet_synced: false` and let a job retry unsynced rows every few minutes. The sheet is a mirror; it should never be the only copy of anything.

Run one test before building anything

Before asking for the full sync, ask for a tiny function that reads `Menu!A1:E3` and returns it as JSON, then press Invoke on it in the Edge Functions section. Three outcomes cover almost every setup problem. A permission error means the sheet is not shared with the service account email. A 'requested entity was not found' error means the spreadsheet id or tab name is wrong (tab names are case-sensitive, and a space in the name needs quoting in the range). An error parsing the key means the JSON was pasted with its line breaks mangled; paste the whole file again as one value. Once three rows come back, the rest is mapping and validation.

Paste-ready brief

Connect my bakery app to Google Sheets with a service account. The key JSON is in Secrets as GOOGLE_SERVICE_ACCOUNT_JSON and the spreadsheet id as SHEET_ID. Write an edge function sync-menu that reads the Menu tab, maps columns by header name (id, Item, Price, Category, Available, Allergens), validates each row, upserts into a menu_items table by id, marks rows missing from the sheet as unavailable instead of deleting them, and records invalid rows in sync_errors with the row number and reason. Run it every 10 minutes and add a Sync now button on the admin page that shows the last sync time and any errors. Also write append-order-row: after each order is saved, append one row to the Orders tab; on failure set sheet_synced to false and retry unsynced orders every 5 minutes.

Pitfalls specific to spreadsheets

  • Column positions change. Someone inserts a 'Notes' column and every price shifts one place. Map by header text and fail loudly when a required header is missing.
  • Formatted values lie. A cell showing `$4.50` may hold `4.5`; a date may come back as a serial number depending on the render option. Pick one value render option and parse explicitly.
  • Quota errors (HTTP 429). Batch reads into one range request, retry with exponential backoff, and never call the API from a loop over rows.
  • The key leaks. The service account can read every sheet shared with it. Keep the JSON only in Secrets, share only the sheets it needs, and rotate the key if it ever appears in code or a screenshot.
  • 'Anyone with the link' sharing. Teams often flip this to make the integration work. It is never required with a service account; share with its email instead.
  • Two writers. If both the app and humans edit the same rows, decide who wins. The simplest rule: the app only appends; humans own edits; the sync reads.

When to stop using the sheet

Signs you have outgrown it: more than a few thousand rows, several people editing at once and overwriting each other, a need for permissions per row, or a sync that takes longer than its schedule. At that point move editing into an admin screen backed by your database, keep a one-way export to Sheets for the people who like it, and retire the import.

Frequently asked questions

Can I use Google Sheets as the database for my app?

For a prototype or a small internal tool, yes. For anything public, sync the sheet into a real database on a schedule: the Sheets API has request quotas and is slow per call, and people can break the structure by editing.

Where do I put the Google service account key?

Paste the full JSON key into Backend → Secrets as one secret and read it only from an edge function. Never put it in frontend code, a client .env variable or a committed file.

Why does the API say the caller does not have permission?

Almost always the sheet is not shared with the service account email address. Share it as Viewer or Editor, exactly as you would with a person.

How fresh can the data be?

A sync every 5 to 15 minutes suits most menus, catalogs and schedules, plus a manual Sync now button for urgent edits. If you need instant updates, the data probably belongs in your app, not a sheet.

On this page

  • Three ways to connect, and when each fits
  • What you need
  • Reading: sync, do not proxy
  • Writing: append on events
  • Run one test before building anything
  • Paste-ready brief
  • Pitfalls specific to spreadsheets
  • When to stop using the sheet

Keep reading

More in Integrations
Editorial ink illustration of a folded paper street map with a brass compass and pushpins, the center pushpin in ember orange
IntegrationsNovember 22, 2026

How to add a map to your app

A map is two jobs: drawing tiles in the browser and turning addresses into coordinates. One key can be public, the other never should be.

6 min read
Editorial ink illustration of a carrier pigeon on a windowsill with a rolled note tied to its leg, the note in ember orange
IntegrationsNovember 22, 2026

How to send SMS from your app

Sending one text is ten lines of code. Sending texts people agreed to, that arrive, and that nobody can abuse, is the real work.

5 min read

Read less. Ship more.

Everything in this post is one prompt away. Describe your app and watch it build.

Start building

Apps, games, backends and publishing from one conversation.

Product

  • Features
  • Use cases
  • Pricing
  • Changelog

Resources

  • Blog
  • Docs
  • Support
  • Status
  • Security

Contact

  • w@startbase.ai
  • X / Twitter
  • LinkedIn
  • Instagram

Legal

  • Terms
  • Privacy

© 2026 Startbase. All rights reserved.