A starter to create and manage a storefront with Gatsby, Stripe, & Netlify Functions; includes cart, checkout, admin, and live data.
- Create and manage inventory through admin interface
- Statically generate based on Stripe inventory
- Dynamically update with live inventory & availability data
- Checkout powered by Stripe
- Serverless functions interact with Stripe API
-
Create a new site from this starter
gatsby new <project-name> https://github.com/brxck/gatsby-starter-stripe
-
Setup Stripe
To get you started quickly, this starter comes with test data in the form of Stripe fixtures. To install the fixtures, first install and configure the Stripe CLI.
Next, from the project folder:
stripe fixtures ./stripe-fixtures.json
⚠️ ACannot query field
error usually means that they queried field is empty in all of your products/prices. If a field is empty Gatsby cannot add it to the GraphQl schema. Either define the field in your Stripe data, or remove it from the query in question. -
Configure API keys
Rename
.env.example
to.env
and fill with your Stripe API test keys. Don't commit this file to a public repo! -
Start development servers
You will need to install and configure the Netlify CLI:
npm install netlify-cli -g
To start the development servers for Gatsby & Netlify Functions simply run Netlify Dev.
netlify dev
Your site is accessible at
http://localhost:8888
!⚠️ Make sure to use the proxied Netilfy Dev server at:8888
! Otherwise your Gatsby application will not be able to access your Netlify Functions. -
Start developing
This starter aims to handle some of the plumbing needed to integrate Gatsby & Stripe. Everything else is left to you and your preferred methods.
The source files for Netlify Functions are located at
/src/functions
, they are then built into the files in/functions
. Visit the documentation for more information on their structure. -
Deploy to Netlify
netlify deploy
You will need to enable Netlify Identity for authentication into the admin area.
If you want to deploy somewhere other than Netlify, you'll have to find another place to deploy the serverless functions in
/functions
, ex. AWS Lambda.
Issues and pull requests welcome!
Thanks @njosefbeck for authoring and maintaining gatsby-source-stripe, which makes this starter possible!