Fireship · @fireship

Google Sheets… Your Next Database?

Uploaded June 23, 2021 · Length 7:16

Google Sheets… Your Next Database?

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.

  1. 0:00

    what if i told you there is a database

  2. 0:01

    that is 100 free

  3. 0:03

    has a world-class admin ui and almost

  4. 0:05

    everybody in the world knows how to use

  5. 0:07

    it that's impossible believe it or not

  6. 0:09

    google sheets the spreadsheet software

  7. 0:11

    can be used as a lightweight database or

  8. 0:13

    headless cms

  9. 0:14

    as the data layer in your application

  10. 0:16

    stack and that's exactly what i'll show

  11. 0:17

    you how to do today

  12. 0:18

    by integrating google sheets with nexjs

  13. 0:21

    in the process you'll learn how to

  14. 0:22

    easily fetch data from a google sheet

  15. 0:24

    in any server side node.js application

  16. 0:27

    which also opens the door to connecting

  17. 0:28

    hundreds of other google apis to your

  18. 0:30

    server

  19. 0:31

    if you're new here like and subscribe

  20. 0:32

    and follow along with the full write-up

  21. 0:34

    on fireship i o

  22. 0:35

    but before you get too excited about

  23. 0:37

    this amazing old tech there are some

  24. 0:38

    important caveats when using google

  25. 0:40

    sheets as your primary database

  26. 0:42

    first of all it was never designed to be

  27. 0:44

    an app database it's not going to be

  28. 0:45

    acid compliant

  29. 0:46

    and doesn't support joins or complex

  30. 0:48

    queries actual data storage only scales

  31. 0:51

    to 5 million cells

  32. 0:52

    and there's also an api quota that

  33. 0:54

    limits you to 500 requests per 100

  34. 0:56

    seconds

  35. 0:57

    but even with those limitations google

  36. 0:59

    sheets actually makes a great little

  37. 1:00

    database for prototyping

  38. 1:02

    and there's really nothing stopping you

  39. 1:03

    from using it in production if you're

  40. 1:05

    building a jam stack site you could use

  41. 1:06

    it as a headless cms and it's very

  42. 1:08

    unlikely that you'll ever hit the api

  43. 1:10

    quota or storage limits but most

  44. 1:12

    importantly

  45. 1:13

    it's super easy to use so let's jump

  46. 1:15

    right into things the first step

  47. 1:16

    is to create a google sheet and add some

  48. 1:18

    data to it you'll notice i have two

  49. 1:20

    columns here

  50. 1:21

    one for the title and one with content

  51. 1:23

    in the form of html

  52. 1:24

    now to fetch or query data from the

  53. 1:26

    sheet all you have to do is highlight it

  54. 1:28

    and you'll notice when you do that

  55. 1:29

    that it creates a range of cells up here

  56. 1:31

    in the top left corner that'll come into

  57. 1:33

    play later when we start making requests

  58. 1:35

    through the api

  59. 1:36

    now in order to make the sheet available

  60. 1:37

    to the app we need to share it publicly

  61. 1:40

    when you click the share button

  62. 1:41

    it generates a url and inside that url

  63. 1:44

    you'll notice an id

  64. 1:45

    which is the id of the sheet itself

  65. 1:47

    you'll want to make a note of that id

  66. 1:48

    for later the next step

  67. 1:50

    is to generate our next js application

  68. 1:52

    and keep in mind

  69. 1:53

    you can follow the same basic process

  70. 1:55

    for any node.js server

  71. 1:56

    we can run npx create next app from the

  72. 1:58

    command line

  73. 1:59

    and then open it up in vs code whenever