Skip to main content
The SDK, the embed and the Checkout Kit are each one script tag. On a site built with npm, two packages put them in your code instead:
Both load Shoply’s own hosted scripts from shoply.gg, the same files a script tag loads. A fix to one reaches your site without you updating the package. Each script is loaded once a page, the first time something asks for it. They run in the browser. With a framework that renders on a server (Next.js, Remix), the React components draw their element there and start once they are in the browser. With @shoplygg/js, call it from an effect or an event handler, not while rendering.

With React

The SDK

shoply is null until the SDK has started. Every method is in the SDK reference. options on the provider are shoply.init()’s, such as currency and track. A site whose router changes the page without loading one counts each page it shows:

The embed

A button that opens the checkout over the page. It takes the embed’s options (product, variant, quantity, coupon, theme, email, billing) and anything a button takes. useEmbed() answers open and close, to open it from anywhere else.

The Checkout Kit

Put the pieces anywhere under <CheckoutKit>, one of them checkout or payment. Its options are the Kit’s, and a change to them after it is up (the cart, the look) is passed to the Kit, so the checkout follows your page’s own basket. useCheckoutKit() answers the Kit, for kit.pay() from a button of your own. onPaid tells the page only: it is no proof of payment. Your server hears of a paid order from webhooks.

Without React

Types

Both packages carry TypeScript types: the store, products, variants, the basket, the embed’s and the Kit’s options and events. A field Shoply adds later is there before the types name it, as unknown.