DEV Community

Discussion on: Build a Multi-Page Gatsby Site from JSON

Collapse
 
ashleemboyer profile image
Ashlee (she/her)

This is something I'm not too sure about! I think all of the pages are generated on build, not on load, so you would have to load all of your data into GraphQL on build and then make your app access GraphQL, rather than the API directly.

I am more sure that this is a doable approach, because does show that you can pull data from APIs on their home page! I've not looked to deeply into the following GitHub repo, but it might be helpful for answering your question!

GitHub logo ryanflorence / gatsby-source-firebase

Gatsby plugin to turn Firebase into a Gatsby data source.

Gatsby Firebase Source

Quick and dirty firebase source for Gatsby. Allows you to query your firebase data right into your statically generated pages with Gatsby.

screenshot

Usage

  1. First you need a Private Key from firebase for privileged environments, find out how to get it here: firebase.google.com/docs/admin/setup (or click the settings gear > Service accounts tab > Generate New Private Key button at the bottom)

  2. Place that private key .json file somewhere in your gatsby project (the root is fine).

  3. Configure gatsby-config.js

// the plugin options are:
{
  credential
  databaseURL
  types: [{
    type
    path
    query,
    map
  }]
}

// Here's an example:

module.exports = {
  // the rest of your config
  plugins: [
    {
      resolve: `gatsby-source-firebase`,
      options: {
        // point to the firebase private key downloaded
        credential: require("./firebase-key.json"),

        // your firebase database root url
        databaseURL: "