Real World Performance: lazy loading, optimizing media, faster analytics join us Wednesday

ContactSign Up
Community Plugin
View plugin on GitHub


Downloads and caches a Google Drive folder that you can then query with gatsby-source-filesystem. Optionally exports Google Docs to a usable format.

This is still a work in progress.


yarn add @fs/gatsby-plugin-drive


In order to use this plugin, you’ll need to generate a Google Service Account and share your drive folder with its email. Here’s a guide.

// In your gatsby-config.js

plugins: [
    resolve: '@fs/gatsby-plugin-drive',
    options: {
      folderId: 'GOOGLE_DRIVE_FOLDER_ID',
      keyFile: path.resolve(__dirname, 'YOUR_SERVICE_ACCOUNT_KEYFILE.json'),
      destination: path.join(__dirname, 'src/content'),
      exportGDocs: true,
      exportMimeType: 'text/html',
      exportMiddleware: someFunction

If the exportGDocs option is enabled, all Google Docs in the folder will be exported with the MIME type set in the exportMimeType option. You can see a list of available Google Docs export MIME types here. If the exportGDocs option is disabled, all Google Docs in the folder will be ignored.

The exportMiddleware option is optional. If set, the plugin will run each Google Doc through the function, before it writes it to disk. A usecase for this, could be cleaning up, or manipulating, the HTML that the Google Drive API returns.
The expected function signature is Buffer -> Buffer.

Your drive folder will download all files everytime it builds, except when a file already exists or is cached. To download all files again, set up an npm clean script like:

"clean": "rimraf src/content",


© 2023 Gatsby, Inc.