Migrate to Netlify Today

Netlify announces the next evolution of Gatsby Cloud. Learn more

ContactSign Up
Community Plugin
View plugin on GitHub


A plugin for integrating Affirm JS payment options with Gatsby.


npm install gatsby-plugin-affirm-js

# or

yarn add gatsby-plugin-affirm-js

Configuration and usage


In the root of your Gatsby project, create 2 environment variables files (.env.development and .env.production) if you don’t have them already, then ddd this key and value.



Add the pulugin and its options to gatsby-config.js in your project.

// 1. Import your .env files
  path: `.env.${process.env.NODE_ENV}`,

module.exports = {
  plugins: [
    // 2. add the plugin
      resolve: "gatsby-plugin-affirm-js",
      options: {
        // 3. pass in the API key in the options
        AFFIRM_API_KEY: `${process.env.AFFIRM_API_KEY}`,

You can now access the Affirm object in your React code using window.affirm. For example

© 2023 Gatsby, Inc.