• Stars
    star
    421
  • Rank 102,977 (Top 3 %)
  • Language
    JavaScript
  • License
    Other
  • Created almost 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ› Simple starter to build a blazing fast Shopify store with Gatsby.

Gatsby
Gatsby Shopify starter

JamStackBox Status

Kick off your next eCommerce experience with this Gatsby starter. It is based on the default Gatsby starter to be easily modifiable. Demo

Unfortunately Shopify prohibits to share access tokens in public repositories, therefore you have to to create your own Shopify Shop and put those credentials in the template.env file and rename it to .env.development as well as .env.production. There are two files if you want to use a different store for you development.

To obtain your own credentials you need the create a custom app in the Shopify frontend and enable the Storefront as well as the Admin API.

If you have questions feel free to message me on Twitter ๐Ÿค™๐Ÿป

Checkout nureineburg.alexanderhoerl.de for a real public shop built with this starter, the code is also public.

๐Ÿ’Ž Features

  • Cart
  • Product grid
  • Product page
  • Dynamic Inventory Checking
  • Image optimization with Gatsby Image
  • Styled Components with Emotion
  • Google Analytics
  • SEO

๐Ÿ“ฆ Dynamic Inventory Checking

The Shopify product inventory is being checked in realtime, therefore no rebuilding and redeploy is needed when a product goes out of stock. This avoids problems where products could still be available even though they're out of stock due to redeploy delay.

๐Ÿ–Œ Styling

I'm using Emotion as styled components library, but the starter is purposely only sparsely styled so you don't have to remove unecessary code but can instead add your own styling immediately.

โš ๏ธ Common problems

  • You need to use the Shopify Storefront API credentials not the regular Shopify API.
  • You need to have at least one published product on Shopify.

๐Ÿš€ Quick start

  1. Create a Gatsby site.

    Use the Gatsby CLI to create a new site, specifying this starter.

    # create a new Gatsby site using this starter
    gatsby new my-shopify-store https://github.com/AlexanderProd/gatsby-shopify-starter
  2. Start developing.

    Navigate into your new siteโ€™s directory and start it up.

    cd my-shopify-store/
    gatsby develop
  3. Open the source code and start editing!

    Your site is now running at http://localhost:8000!

    Note: You'll also see a second link: http://localhost:8000/___graphql. This is a tool you can use to experiment with querying your data. Learn more about using this tool in the Gatsby tutorial.

    Open the my-shopify-store directory in your code editor of choice and edit src/pages/index.js. Save your changes and the browser will update in real time!

  4. Connect your own Shopify store.

    Open both .env files located in the root directory of your page end replace the credentials with your own. Don't forget to restart Gatsby for your store to be loaded!

    โš ๏ธ Make sure to use the Shopify storefront API credentials, not the regular Shopify API!

Deploy

Checkout my other open-source project JAMStackBox to continuously deploy your Gatsby site on your own server.

๐ŸŽ“ Learning Gatsby

Looking for more guidance? Full documentation for Gatsby lives on the website. Here are some places to start:

  • For most developers, we recommend starting with our in-depth tutorial for creating a site with Gatsby. It starts with zero assumptions about your level of ability and walks through every step of the process.

  • To dive straight into code samples, head to our documentation. In particular, check out the Guides, API Reference, and Advanced Tutorials sections in the sidebar.

๐Ÿ“Œ ToDo

I'll happily merge any pull request to improve the starter. ๐Ÿ™‚

  • Convert Layout to function component.
  • Add dynamic inventory checking to avoid re-building after every purchase.
  • Add better styling.
  • Add image optimization using Gatsby sharp plugin.
  • Convert ProductForm to function component.