Buy Button JS

You can use the Shopify Buy Button JS library to embed customizable Shopify UI components, such as product listings and shopping carts, directly into any website. The library uses the JS Buy SDK to connect to a Shopify store, giving you access to its products and collections.

Requirements

  • You've created a development store or have a production store.
  • You've created products or collections in your store.
  • You have a website and want to add ecommerce functionality to it.

1. Generate an access token

To generate an access token, you create a private app.

When you create the private app, make sure to enable Allow this app to access your storefront data using the Storefront API, and select which types of data you want to expose to the app.

The access token is generated when you save the private app. You include the access token with any requests made from your app to Shopify.

2. Make your products and collections available

After you've generated an access token, you need to make products and collections available to your private app to access them from your app. After the products and collections are available, you can retrieve them using their respective IDs.

Make a product available

  1. From your Shopify admin, go to Products.
  2. From the Products page, click the product you want to make available.
  3. Next to SALES CHANNELS AND APPS click Manage.
  4. In the Sales channels and apps dialog box, select the box next to the name of your private app.

Make a collection available

  1. From your Shopify admin, go to Products and click Collections.
  2. From the Collections page, click the collection you want to make available.
  3. Next to SALES CHANNELS AND APPS click Manage.
  4. In the Sales channels and apps dialog box, select the box next to the name of your private app.

3. Access the Buy Button JS

Using the Buy Button JS, you can add the following components to your website:

  • Product listings and Buy Now buttons
  • Collections of products
  • A shopping cart

View BuyButton.js on GitHub.

Where to get help

This SDK isn't supported by Shopify support, but there are other places where you can get help.

Open a GitHub issue

You can open an issue in the GitHub repository.

Shopify Community forums

Visit our forums to connect with the community and learn more about the Shopify API and App development.

Shopify Experts

Find an Expert for hire in our ecosystem of talented development agencies.