1.0.2 • Published 3 years ago

@mstoduto/gatsby-source-remote-config v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

gatsby-source-remote-config npm node

Gatsby plugin for connecting Firebase Remote Config as a data source.

Usage

  1. Generate and download a Firebase Admin SDK private key by accessing the Firebase Project Console > Settings > Service Accounts

  2. Rename and put the downloaded .json crendtial file somewhere in the GatsbyJS project (e.g. ./credentials.json)

  3. Add gatsby-source-remote-config as a dependency by running using npm or yarn:

    npm i @mstoduto/gatsby-source-remote-config
    # or
    yarn add @mstoduto/gatsby-source-remote-config
  4. Configure settings at gatsby-config.js, for example:

module.exports = {
    plugins: [
        {
            resolve: `@mstoduto/gatsby-source-remote-config`,
            options: {
                // credential or appConfig
                credential: require(`./credentials.json`),
                appConfig: {
                    apiKey: 'api-key',
                    authDomain: 'project-id.firebaseapp.com',
                    databaseURL: 'https://project-id.firebaseio.com',
                    projectId: 'project-id',
                    storageBucket: 'project-id.appspot.com',
                    messagingSenderId: 'sender-id',
                    appID: 'app-id',
                },
                parameterGroup: "website",
                fields: [
                    "sections"
                ]
            },
        },
    ],
};

Example

{
  allRemoteConfigParam {
    nodes {
      id
      valueString
      value {
        array {
          content
          order
          title
        }
      }
    }
  }
}

Configurations

KeyDescription
credentialCredential configurations from downloaded private key
fieldsArray of fields to get from remote config
appConfigCredential configurations defined inside object
parameterGroupName of the parameterGroup to use, if none only main folder parameters are shown