SDK Reference
The Chord client-side Javascript SDK is installed as a Gatsby theme. It's available as an npm package, @chordcommerce/gatsby-theme-performance, via GitHub Packages.
Despite the name, this package does not provide a visual theme. To quote from the Gatsby documentation:
Gatsby themes are plugins that include a gatsby-config.js file and add pre-configured functionality, data sourcing, and/or UI code to Gatsby sites. You can think of Gatsby themes as separate Gatsby sites that can be put together and allow you to split up a larger Gatsby project!
The gatsby-theme-performance theme includes the Chord SDK, a set of methods you can import and use in your React components to do things like add items to a cart and check out. The theme also pre-configures your Gatsby site with a number of useful commerce features like product feeds and internationalization support.
The Chord SDK is available to use in your React components via React hooks:
Hook | Description |
---|---|
Provides support for sending UI-related tracking events to Segment. | |
useAuth | Provides support for user authentication with a Shopify customer account. |
useCart | Returns the current shopping cart, and functions for creating and interacting with the shopping cart. |
useUser | Returns the current user, and functions for loading data about the user. |