Migrate to Netlify Today

Netlify announces the next evolution of Gatsby Cloud. Learn more

ContactSign Up
Community Plugin
View plugin on GitHub


Gatsby plugin to apply context to every page

Travis npm

This plugin adds context values to every page in your Gatsby project. Use this if you want to add a “global variable” that any page can use in its GraphQL query.


npm install gatsby-plugin-global-context


Add the plugin to gatsby-config.js:

module.exports = {
  plugins: [
      resolve: 'gatsby-plugin-global-context',
      options: {
        context: {
          kittens: true

Now, any page will have access to the values defined in context above. This includes pages in your pages/ folder, and pages created with Gatsby’s createPage().

import React from 'react';
import { graphql } from 'gatsby';

export default () => <h1>Hi, I am a page</h1>;

export const query = graphql`
  query PageQuery($kittens: Boolean!) {
    # ...


The only option is context, which should be an object of context values to add to every page.

Local Development

git clone https://github.com/gakimball/gatsby-plugin-global-context
cd gatsby-plugin-global-context
npm install
npm test


MIT © Geoff Kimball

© 2023 Gatsby, Inc.