See what's launched

The next gen Gatsby is here Performance, developer velocity, and scaling to meet Enterprise needs - See what’s launched

Gatsby REPL

The Gatsby REPL (“read-eval-print loop”) is available via the Gatsby CLI by running the command gatsby repl. This gives you access to an interactive REPL shell within the context of your Gatsby environment. It can be used to retrieve general data and programmatically interact with it. If you have an idea for a new command, feel free to submit a PR for it!

This doc will give a brief description of each REPL command, expected output, and an example of what you can do with the command to digest the data. Examples are using the Gatsby Starter Blog as a demo environment, since it is currently the highest rated starter, and provides standard output for most of these commands.

To get started, in your terminal, after running the initial site setup steps here, run the command gatsby repl to enter the interactive shell. If you are writing out a function, you can write that over multiple lines, as long as you do not use a semicolon or close a parenthesis or brace prematurely. This is helpful for running GraphQL queries and callback functions.

REPL Commands


Returns an object with the global babelrc settings.

Usage: babelrc



Returns a Map object with all of the components in your Gatsby environment (see Mozilla Map docs for more information on Map objects and how to use them). Properties that get returned: name, componentPath, query, pages, and isInBootstrap:.

Usage: components



Get a single node by its ID, typically a string.

Usage: getNode(<id>)



Returns an array of objects (the nodes).

Usage: getNodes()



nodes is like getNodes(), but returns an indexed array of objects (the nodes). You can also pass in the index of the node you want, and that will return an array with a single node object.

Usage: nodes returns the array, or nodes[<id>] returns an array with a node object.



Returns an indexed array of arrays. Each array contains a key which is the slug, and a value which is the page node object.

Usages: pages or pages[<index>]



Returns the GraphQL schema of your Gatsby environment as an object.

Usages: schema or schema[<property>]



Returns the settings you would find in the gatsby-config.js file of your site as an object.

Usages: siteConfig or siteConfig[<property>]



Returns a Map object with all of the static queries in your Gatsby environment. Properties that get returned: name, componentPath, id, query, and hash.

Usage: staticQueries


Edit this page on GitHub
© 2022 Gatsby, Inc.