Fireship · @fireship
Google Sheets… Your Next Database?
Uploaded June 23, 2021 · Length 7:16
Summary
using google sheets as a lightweight database or headless cms with next js and node.js
- google sheets database
- next js headless cms
- google sheets api
- node js google api
- google cloud platform
- google sheets as database
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
what if i told you there is a database
- 0:01
that is 100 free
- 0:03
has a world-class admin ui and almost
- 0:05
everybody in the world knows how to use
- 0:07
it that's impossible believe it or not
- 0:09
google sheets the spreadsheet software
- 0:11
can be used as a lightweight database or
- 0:13
headless cms
- 0:14
as the data layer in your application
- 0:16
stack and that's exactly what i'll show
- 0:17
you how to do today
- 0:18
by integrating google sheets with nexjs
- 0:21
in the process you'll learn how to
- 0:22
easily fetch data from a google sheet
- 0:24
in any server side node.js application
- 0:27
which also opens the door to connecting
- 0:28
hundreds of other google apis to your
- 0:30
server
- 0:31
if you're new here like and subscribe
- 0:32
and follow along with the full write-up
- 0:34
on fireship i o
- 0:35
but before you get too excited about
- 0:37
this amazing old tech there are some
- 0:38
important caveats when using google
- 0:40
sheets as your primary database
- 0:42
first of all it was never designed to be
- 0:44
an app database it's not going to be
- 0:45
acid compliant
- 0:46
and doesn't support joins or complex
- 0:48
queries actual data storage only scales
- 0:51
to 5 million cells
- 0:52
and there's also an api quota that
- 0:54
limits you to 500 requests per 100
- 0:56
seconds
- 0:57
but even with those limitations google
- 0:59
sheets actually makes a great little
- 1:00
database for prototyping
- 1:02
and there's really nothing stopping you
- 1:03
from using it in production if you're
- 1:05
building a jam stack site you could use
- 1:06
it as a headless cms and it's very
- 1:08
unlikely that you'll ever hit the api
- 1:10
quota or storage limits but most
- 1:12
importantly
- 1:13
it's super easy to use so let's jump
- 1:15
right into things the first step
- 1:16
is to create a google sheet and add some
- 1:18
data to it you'll notice i have two
- 1:20
columns here
- 1:21
one for the title and one with content
- 1:23
in the form of html
- 1:24
now to fetch or query data from the
- 1:26
sheet all you have to do is highlight it
- 1:28
and you'll notice when you do that
- 1:29
that it creates a range of cells up here
- 1:31
in the top left corner that'll come into
- 1:33
play later when we start making requests
- 1:35
through the api
- 1:36
now in order to make the sheet available
- 1:37
to the app we need to share it publicly
- 1:40
when you click the share button
- 1:41
it generates a url and inside that url
- 1:44
you'll notice an id
- 1:45
which is the id of the sheet itself
- 1:47
you'll want to make a note of that id
- 1:48
for later the next step
- 1:50
is to generate our next js application
- 1:52
and keep in mind
- 1:53
you can follow the same basic process
- 1:55
for any node.js server
- 1:56
we can run npx create next app from the
- 1:58
command line
- 1:59
and then open it up in vs code whenever


