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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@kyakaze/judgeme-hydrogen

v1.0.1

Published

This module helps integrate Judge.me Widgets to Hydrogen app. Currently, it works mostly on the client side. Judge.me review data will be fetched from Judge.me CDN (not from metafields) # Getting Started **Requirements:** - Node.js version 16.5.0 or highe

Downloads

4

Readme

Hydrogen x Judge.Me Widgets

This module helps integrate Judge.me Widgets to Hydrogen app. Currently, it works mostly on the client side. Judge.me review data will be fetched from Judge.me CDN (not from metafields)

Getting Started

Requirements:

  • Node.js version 16.5.0 or higher
  • Yarn

Installation:

  • Install module: npm i @kyakaze/judgeme-hydrogen
  • Remember to update hydrogen.config.js with your shop's domain and Storefront API token!
  • Edit content and rename .env.development.example to .env.development OR update these variables:
JUDGEME_SHOP_DOMAIN="your shop domain"
JUDGEME_PUBLIC_TOKEN="judge.me public token"
JUDGEME_CDN_HOST="https://cdn.judge.me"
  • Install devs npm install
  • Start dev server: npm run dev

Deploy

Usage:

A. Config:

  <JudgemeProviderWrapper
      shopDomain={Oxygen.env.JUDGEME_SHOP_DOMAIN}
      publicToken={Oxygen.env.JUDGEME_PUBLIC_TOKEN}
      cdnHost={Oxygen.env.JUDGEME_CDN_HOST}
  >

Using Module:

There are 2 ways to use this module in your project:

1. Using predefined composition Provider

import {JudgemeProviderWrapper} from "@kyakaze/judgeme-hydrogen";

//...
function App() {
  return (
    <Suspense fallback={null}>
      <ShopifyProvider>
        <JudgemeProviderWrapper>
          <CartProvider>
            <Router>
              <FileRoutes/>
            </Router>
          </CartProvider>
        </JudgemeProviderWrapper>
      </ShopifyProvider>
    </Suspense>
  );
}

Our module uses external script from Judge.me core server, therefore any changes will not be detected by React. Using this JudgemeProviderWrapper will automatically re-render widgets after they are loaded.

If you don't want to trigger it on every page, consider the second approach.

2. Manually load widget

Firstly, add the Provider

import {JudgemeProvider} from "@kyakaze/judgeme-hydrogen";

function App() {
  return (
    <Suspense fallback={null}>
      <ShopifyProvider>
        <JudgemeProvider/>
        <CartProvider>
          <Router>
            <FileRoutes/>
          </Router>
        </CartProvider>
      </ShopifyProvider>
    </Suspense>
  );
}

Then you can load widgets on a selected page or component by adding <JudgemePreloader /> component at the end of pages or components (preferably pages since you should render this component only once to avoid mismatch between server and client DOM error) in which you use the widgets.

  • Example for loading one widget inside a component:
import {JudgemePreviewBadgeClient, JudgemePreloader} from "@kyakaze/judgeme-hydrogen";

function SampleComponent({product}) {
  return (
    <div>
      <JudgemePreviewBadgeClient id={product.id}/>
      <JudgemePreloader/>
    </div>
  )
}
  • Example for loading multiple widgets inside a component:
import {JudgemePreviewBadgeClient, JudgemePreloader} from "@kyakaze/judgeme-hydrogen";

function SampleComponent({products}) {
  return (
    <div>
      {products.map(product => {
        return <JudgemePreviewBadgeClient id={product.id}/>
      })}
      <JudgemePreloader/>
    </div>
  )
}
  • Example for loading many widgets nested inside a page:
import {
  JudgemePreviewBadgeClient,
  JudgemeCarouselClient,
  JudgemeVerifiedBadgeClient,
  JudgemePreloader
} from "@kyakaze/judgeme-hydrogen";

// ...
function SampleComponent({products}) {
  return (
    <div>
      {products.map(product => {
        return <JudgemePreviewBadgeClient id={product.id}/>
      })}
      <JudgemeCarouselClient/>
      <JudgemeVerifiedBadgeClient/>
      <SomeOtherComponentWhichUseJudgemeWidgets/>
      <JudgemePreloader/>
    </div>
  )
}

B. Widgets:

Currently we support only client widget components. Here is the list of our widget components:

import {
  JudgemeMedalsClient,
  JudgemeCarouselClient,
  JudgemeReviewsTabClient,
  JudgemePreviewBadgeClient,
  JudgemeReviewWidgetClient,
  JudgemeVerifiedBadgeClient,
  JudgemeAllReviewsCountClient,
  JudgemeAllReviewsRatingClient,
} from "@kyakaze/judgeme-hydrogen";

Review Widget

  • Component name: JudgemeReviewWidgetClient
  • Required props: product id, it could be either shopify graph ID or simply ID: gid://shopify/Product/12345678, 12345678.

Preview Badge

  • Component name: JudgemePreviewBadgeClient
  • Required props: product id, it could be either shopify graph ID or just ID: gid://shopify/Product/12345678, 12345678.

TODO: Use table for better UIUX


References

Hydrogen is a React framework and SDK that you can use to build fast and dynamic Shopify custom storefronts.

Check out the docs

Run this template on StackBlitz