🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

gatsby-transformer-react-docgen

Package Overview
Dependencies
Maintainers
7
Versions
437
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gatsby-transformer-react-docgen

Expose React component metadata and prop information as GraphQL types

latest
Source
npmnpm
Version
8.16.0
Version published
Weekly downloads
2.5K
172.56%
Maintainers
7
Weekly downloads
 
Created
Source

gatsby-transformer-react-docgen

Parses inline component-documentation using react-docgen.

Install

npm install gatsby-transformer-react-docgen

Usage

Add a plugin-entry to your gatsby-config.js

module.exports = {
  plugins: [`gatsby-transformer-react-docgen`],
}

For custom resolvers or handlers, all config options are passed directly to react-docgen. In addition any custom handlers are passed the component file Node object as their last argument for more Gatsby specific handler behavior.

module.exports = {
  plugins: [
    {
      resolve: "gatsby-transformer-react-docgen",
      options: {
        resolver: require("./custom-resolver"),
      },
    },
  ],
}

File parsing and babel configs

By default, your local .babelrc will be used to determine how to parse source files. Don't worry if you don't have a local babel config and are using Gatsby's default settings! If there isn't any config react-docgen will use it's own, permissive parsing options.

In the case of more complex sites with local custom configs, such as in a monorepo, you may have to tell babel (via react-docgen), how to properly resolve your local babel config. See the react-docgen documentation for more details.

module.exports = {
  plugins: [
    {
      resolve: "gatsby-transformer-react-docgen",
      options: {
        babelrcRoots: ["../packages/*"],
      },
    },
  ],
}

You'll also need to include a source-plugin, such as gatsby-source-filesystem, so that the transformer has access to source data.

Note: that at least one of your React Components must have PropTypes defined.

How to query

An example graphql query to get nodes:

{
  allComponentMetadata {
    edges {
      node {
        displayName
        description
        props {
          name
          type
          required
        }
      }
    }
  }
}

Keywords

gatsby

FAQs

Package last updated on 26 Jan 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts