npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

bloy-dong-hydrogen-sdk

v1.0.2

Published

BLOY Loyalty SDK for Shopify Headless Commerce and Hydrogen

Readme

BLOY Hydrogen SDK

Official SDK for integrating BLOY Loyalty widgets into Shopify Hydrogen and custom headless storefronts.


Features

  • Loyalty Widget
  • VIP Program
  • Product Point Calculator
  • Redeem Rewards on Cart
  • Headless Authentication
  • Theme Synchronization
  • Shopify Hydrogen Support

Installation

npm install bloy-dong-hydrogen-sdk

or

yarn add bloy-dong-hydrogen-sdk

or

pnpm add bloy-dong-hydrogen-sdk

Requirements

  • Shopify Hydrogen
  • React 18+
  • Shopify Storefront API
  • BLOY Loyalty installed on Shopify

Environment Variables

Configure the following variables in Hydrogen:

PUBLIC_BLOY_CDN_URL=https://cdn.bloy.io
BLOY_API_URL=https://api.bloy.io
BLOY_CMS_URL=https://cms.bloy.io

# Secret provided by BLOY
BLOY_TOKEN_SECRET=xxxxxxxxxxxxxxxx

Setup

1. Load BLOY Data in Root Loader

import { getBloyConfigData } from 'bloy-dong-hydrogen-sdk';

async function loadCriticalData({ context }) {
  const { storefront, session, customerAccount } = context;

  let customer = null;

  if (await customerAccount.isLoggedIn()) {
    customer = await customerAccount.query(CUSTOMER_QUERY);
  }

  const header = await storefront.query(HEADER_QUERY);

  const shopDomain =
    header.shop.primaryDomain.url.replace('https://', '');

  const bloyData = await getBloyConfigData({
    storefront,
    session,
    env: context.env,
    shopDomain,
    customer: {
      id:
        customer?.data?.customer?.id?.replace(
          'gid://shopify/Customer/',
          '',
        ) || '',
      email:
        customer?.data?.customer?.emailAddress?.emailAddress || '',
    },
  });

  return {
    header,
    ...bloyData,
  };
}

2. Initialize BLOY

Inside root.jsx:

import { useRouteLoaderData } from 'react-router';
import { useBloyLoyalty } from 'bloy-dong-hydrogen-sdk';

export default function App() {
  const data = useRouteLoaderData('root');

  useBloyLoyalty(data);

  return <Outlet />;
}

The SDK automatically:

  • Loads BLOY widgets
  • Injects storefront theme settings
  • Loads translations
  • Loads loyalty configuration
  • Synchronizes customer session
  • Initializes headless storefront globals

3. Product Point Calculator

import { useBloyProductCalculator } from 'bloy-dong-hydrogen-sdk';

export default function Product() {
  const { product } = useLoaderData();

  useBloyProductCalculator({ product });

  return (
    <div className="BLOY-point-calculator__container" />
  );
}

4. Redeem Rewards on Cart

import { useBloyCart } from 'bloy-dong-hydrogen-sdk';

export default function Cart() {
  const { cart } = useLoaderData();

  useBloyCart({ cart });

  return (
    <div className="BLOY-cart__rewards" />
  );
}

Authentication

The SDK uses a two-step authentication process for headless storefronts.

Step 1

Generate a temporary configuration token:

HMAC_SHA256(
  shopDomain.customerId,
  BLOY_TOKEN_SECRET
)

Used to securely fetch storefront configuration.

Step 2

After configuration is loaded, the SDK generates a customer token:

HMAC_SHA256(
  shopId.customerId,
  BLOY_TOKEN_SECRET
)

Used by loyalty widgets to authenticate the customer.

No manual token generation is required by the merchant.


API Reference

getBloyConfigData()

Fetches BLOY storefront configuration.

Parameters

{
  storefront: any;
  session: any;
  env: any;
  shopDomain: string;
  customer?: {
    id?: string;
    email?: string;
  };
}

Returns

{
  bloy: {
    shopId: string;
    storeDomain: string;
    customer: {
      id: string;
      email: string;
      token: string;
    };
    cdnUrl: string;
    apiUrl: string;
    cmsUrl: string;
    headlessConfig: any;
  };
}

useBloyLoyalty()

useBloyLoyalty(data);

Initializes global BLOY widgets.


useBloyProductCalculator()

useBloyProductCalculator({
  product,
});

Initializes Product Point Calculator.


useBloyCart()

useBloyCart({
  cart,
});

Synchronizes Hydrogen cart data with BLOY Cart Widget.


Widget Containers

Product Calculator

<div class="BLOY-point-calculator__container"></div>

Cart Rewards

<div class="BLOY-cart__rewards"></div>

Troubleshooting

Widget does not appear


Verify:

```javascript
window.BloyConfigs.shop_id

contains a valid value.


Authentication failed

Verify:

BLOY_TOKEN_SECRET

matches the secret provided by the BLOY team.


Loader script not loaded

Verify:

PUBLIC_BLOY_CDN_URL

is configured correctly.


License

MIT