Migrate to Netlify Today

Netlify announces the next evolution of Gatsby Cloud. Learn more

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.


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',
      gtoken: {
        keyFile: path.resolve(__dirname, 'YOUR_SERVICE_ACCOUNT_KEYFILE.json'),
        // key: 'or pass the key as a string instead of the keyfile',
        // email: 'if you pass key also pass the email of the service account',
      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",

Rate Limiting

The default amount of allowed requests per user per 100 seconds is 1,000. If you’re planning to download a large folder with this plugin, you might have to increase this limit. To do that, open the “Services” tab in the Google Cloud Console, select “Google Drive API” and change the limit under “Quotas”.


© 2023 Gatsby, Inc.