Chord OMS
...
Developer Tools
Gatsby

SDK Reference 4.x

5min
introduction the react docid\ ewxkrz0jhh0zpphikkcri can be installed via a gatsby theme it's available as an npm package, @chordcommerce/gatsby theme autonomy , 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! gatsby theme autonomy includes the react docid\ ewxkrz0jhh0zpphikkcri , a set of react hooks that offer an easy way to interact with chord's order management system, for common operations like adding items to a cart these hooks provide access to sdk methods that handle communication with chord's order management system and keep the site's redux state up to date they also automatically send tracking events to segment the theme also pre configures your gatsby site with a number of useful ecommerce features like sitemaps and internationalization support installation yarn npx install peerdeps yarn @chordcommerce/gatsby theme autonomy npm npx install peerdeps @chordcommerce/gatsby theme autonomy this theme uses a significant amount of gatsby plugins and transformers we provide these as peer dependencies instead of vendoring them so that you can upgrade them at your own pace a couple of major things to keep in mind as you upgrade them first party gatsby plugins and gatsby itself should have the same minor version to ensure they are compatible (if you are on the current release of gatsby) for example, we have gatsby\@4 13 1 , gatsby plugin image\@2 13 0 and gatsby plugin sitemap\@5 13 0 note that all of them share a minor version of 13 while the major and patch versions differ this isn't a hard and fast rule but something that you should strive to maintain where possible gatsby plugin sharp and gatsby transformer sharp must be the same version this is because they bundle a binary that having multiple versions of will break builds after installing the package, add the following configuration to your gatsby config js file // gatsby config js module exports = { plugins \[ { resolve 'gatsby theme autonomy', options { contentfulconfig { spaceid process env contentful space id, accesstoken process env contentful access token, host process env contentful api url, environment process env contentful environment, }, omsconfig { brandname process env gatsby chord oms brand name, storeid process env gatsby chord oms store id, omsid process env gatsby chord oms id, tenantid process env gatsby chord oms tenant id, domain process env gatsby chord oms api url, }, intlconfig { languages \[`en us`], defaultlanguage `en us`, path path resolve( dirname, 'src/intl'), }, sitemetadata { title `chord commerce starter`, siteurl `https //www chord co`, description `a starter kit `, social { facebook 'chordcommerce', instagram 'chordcommerce', pinterest 'chordcommerce', }, }, }, }, ], } run your site as usual, using yarn start hooks reference hook description useanalytics https //docs beta chord co/chord ui/function useanalytics provides support for sending ui related tracking events to segment useauth https //docs beta chord co/chord ui/function useauth provides support for user authentication chord supports passwordless authentication with magic https //magic link/ usecart https //docs beta chord co/chord ui/function usecart returns the current shopping cart, and functions for creating and interacting with the shopping cart usecheckout https //docs beta chord co/chord ui/function usecheckout provides support for checkout useproduct https //docs beta chord co/chord ui/function useproduct provides support for interacting with products usesubscription https //docs beta chord co/chord ui/function usesubscription provides support for managing user subscriptions usesubscriptions https //docs beta chord co/chord ui/function usesubscriptions returns the current user's subscriptions usetranslate docid\ ggsuiokkcpgbf0rqshw6y provides support for internationalization useuser https //docs beta chord co/chord ui/function useuser returns the current user, and functions for loading data about the user