Back to Gatsby

Node API Helpers

docs/docs/reference/config-files/node-api-helpers.md

2.20.0924 B
Original Source

The first argument passed to each of Gatsby’s Node APIs is an object containing a set of helpers. Helpers shared by all Gatsby’s Node APIs are documented in Shared helpers section.

js:title=gatsby-node.js
exports.createPages = gatsbyNodeHelpers => {
  const { actions, reporter } = gatsbyNodeHelpers
  // use helpers
}

Common convention is to destructure helpers right in argument list:

js:title=gatsby-node.js
exports.createPages = ({ actions, reporter }) => {
  // use helpers
}

The Creating a Source Plugin tutorial explains some of the Shared helpers in more detail.

Note

Some APIs provide additional helpers. For example createPages provides graphql function. Check documentation of specific APIs in Gatsby Node APIs for details.