SheetLatch / Guides

Use Google Sheets as a database for a Next.js app

A sheet is a fine data store for a small Next.js site when the people who edit the content live in spreadsheets already.

The server component

// app/products/page.js
export const revalidate = 60;

export default async function Products() {
  const res = await fetch("https://sheetlatch-api.quietlathe.com/v1/SHEET_ID/Products?limit=50", {
    headers: { "x-api-key": process.env.SHEET_API_KEY },
  });
  const rows = await res.json();
  return <ul>{rows.map(r => <li key={r.name}>{r.name}: {r.price}</li>)}</ul>;
}

The key stays on the server. The page is rebuilt at most once a minute, and the API cache sits behind that.

Where this stops working

Sheets have no transactions and no per-row permissions. Keep orders, accounts and anything sensitive in a real database, and use the sheet for content, product lists and settings.

Early access. SheetLatch opens soon. Join the early-access list and we will email you once when it does. Planned free plan: 1,000 requests a month. SheetLatch is not affiliated with Google.