---
title: JavaScript SDK & Headless
slug: javascript-sdk-and-headless
description: Learn about the advantages of utilizing SparkLayer's JavaScript SDK for frontend development, such as accessing data, interacting with the GraphQL API, and enhancing cart functionality. Discover how this SDK empowers developers to craft personalized exper
docTags: 
createdAt: 2023-06-13T06:59:08.000Z
---

:::hint{type="success"}
**Get started**
To explore more about the SparkLayer JavaScript SDK, please refer to our [SparkLayer JavaScript SDK](https://docs.sparklayer.io/tech-docs/javascript-sdk) documentation.
:::

## Introduction

With the [SparkLayer JavaScript SDK](https://docs.sparklayer.io/tech-docs/javascript-sdk), you can enhance your frontend development and create more customised experiences for your users. The SDK provides a range of straightforward functions to access data stored within SparkLayer, as well as granting access to the GraphQL API and a cart update function.&#x20;

![](https://api.archbee.com/api/optimize/kxppJrvFK15E9wXbMKaTP/ASvR3txlNK79ZjCvAfrd2_image.png)

## Example use-cases

The SparkLayer SDK empower developers to build more advanced and dynamic applications on top of the SparkLayer platform. Use-cases can include:

| Functionality                            | Description                                                                                                                                                                                                     |
| ---------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Accessing Data and APIs`                | Provides functions to access data within SparkLayer and utilize the GraphQL API, enabling the development of advanced and dynamic applications.                                                                 |
| `Manual Initialization`                  | Allows manual initialization of the SDK, useful in headless commerce implementations                                                                                                                            |
| `Customizing User Experiences`           | Allows calculation of pricing data, updating the shopping cart and retrieving updated cart information, customisation of the look and feel                                                                      |
| `Product Variant Image Updating`         | Custom code can be added to update product images when a variant is selected, enhancing user shopping experience by providing visual feedback.                                                                  |
| `Custom Checkout Validation`             | Enables custom validation logic at checkout for personalized API calls to verify cart contents and manage checkout permissions based on custom rules (e.g., managing one-time discounts, product quota limits). |
| `Adding Custom Attributes to Cart Items` | Offers a method to include custom attributes with cart items, ensuring customizations are visible under the product SKU and persist through to past orders.                                                     |

## Explore more

To explore more about the SparkLayer JavaScript SDK, please refer to our [SparkLayer JavaScript SDK](https://docs.sparklayer.io/tech-docs/javascript-sdk) documentation.

:::hint{type="warning"}
**Please note**
If you're looking to extend your SparkLayer integration by using the SDK, we do strongly recommend speaking to our technical team to ensure it can meet your requirements. Please [contact us here](docId\:NNUw1G9z7eaJ4M78vk7t9)
:::

## Error Codes

Below is a list of error codes that are shown in the SparkLayer Core Script frontend widgets if on of the custom SparkLayer Options hooks fails:

:::hint{type="danger"}
- **OPTIONS\:HOOK\:OR** - window\.sparkOptions.onReady hook failed
- **OPTIONS\:HOOK\:OCL** - window\.sparkOptions.onCartLoad hook failed
- **OPTIONS\:HOOK\:OCU** - window\.sparkOptions.onCartUpdate hook failed

If these errors are reported by customers, please review your store's sparkOptions configuration for the relevant hook and ensure the errors are resolved.

**NOTE:&#x20;**&#x54;he specific JS error is logged to the browser's Console.&#x20;
:::



***

## Headless implementations (Composable Commerce)

SparkLayer has been designed and built to be a fully headless (composable) eCommerce platform and there are a variety of ways it can be extended. To learn more, please see our [headless guide](https://docs.sparklayer.io/tech-docs/headless) for what's possible.
