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

@fast-simon/storefront-kit

v0.0.3

Published

A comprehensive kit for developing storefronts with Fast Simon components, utilities, and React/Hydrogen support.

Downloads

10

Readme

@fast-simon/storefront-kit

@fast-simon/storefront-kit is a versatile library for e-commerce platforms, providing easy integration of Fast Simon features like Visual Similarity and other complex functionalities into your online stores. Written in TSX, it offers a suite of fetcher functions for pulling data from Fast Simon servers and components for rendering, streamlining the integration process.

Features

  • Visual similarity: Enhance product discovery by showing visually similar products.
  • Customizable components: Tailored to fit the design and functionality of your store.
  • Flexible fetcher functions: Retrieve data effectively with minimal setup.
  • Easy integration with Shopify, especially designed for use with Shopify Hydrogen.

Installation

Install the package in your project:

npm install @fast-simon/storefront-kit

Usage

Adding Fast Simon fetcher function to the root loader

  • import getVisualSimilarityProducts from @fast-simon/storefront-kit into the product page root file
  • Invoke getVisualSimilarityProducts in your root loader function, passing the product id as a prop
  • Pass down the result to the product page component, you can either await to the promise to resolved (which could have a negative performance impact) or just pass the promise down as a stream.
import {getVisualSimilarityProducts} from '@fast-simon/storefront-kit';

export async function loader({params, request, context}: LoaderFunctionArgs) {
  // ... other code
  const visualSimilarityProducts = getVisualSimilarityProducts({
    UUID: 'Your store UUID here, you can find it in the Fast Simon dashboard',
    productId: product.id,
    storeId: 'Your store ID here, you can find it in the Fast Simon dashboard',
  });
  return defer({otherparam, visualSimilarityProducts});

Using Fast Simon components

After fetching data using the getVisualSimilarityProducts function, you can display the results using components from the @fast-simon/storefront-kit. Here's an example of how to use the FastSimonWidget component along with retrieving the data using the useLoaderData:

import { FastSimonWidget } from '@fast-simon/storefront-kit';

function ProductPage() {

  const {product, visualSimilarityProducts} = useLoaderData<typeof loader>();

  // ... other component logic

  return (
          <div>

            {/* ... other parts of your product page */}

            <FastSimonWidget title={'Similar Products'}
                             products={visualSimilarityProducts}/>

          </div>
  );
}

This component will render the visual similarity results in a visually appealing and interactive format.

Configuration

getVisualSimilarityProducts function

To customize the behavior of the getVisualSimilarityProducts function, you can pass the specs parameter to control aspects like:

  • maxSuggestions - Max number of similar products to fetch
  • sources - sources of the results, for example:
    • similar_products - products sharing category, tags or keyword similarity with the viewed product
    • similar_products_by_attributes - products sharing categories and chosen attributes (requires choosing relevant attributes in Fast Simon dashboard)
    • similar_products_lookalike - visually similar products (requires enabling Look-a-like Visually Similar Recommendations in Fast Simon dashboard)
    • related_top_products - popular products in the store

Refer to the API documentation for a full list of configurable parameters. https://docs.fastsimon.com/api#operation/productRecommendations

FastSimonWidget component

You can customize the FastSimonWidget component with various props to match your store's design and layout requirements.

renderProduct - a function that receives a product object and returns a React element. This allows you to customize the product card that is rendered for each product in the widget. For example:

  <FastSimonWidget title={'Similar Products'}
                   products={visualSimilarityProducts}
                   renderProduct={(product, pos) => <MyProductCard key={product.id} product={product} />}/>

title - The title of the widget, for example Similar Products or You may also like breakpoints - An object of breakpoints to control the number of products displayed in each device. For example:

  <FastSimonWidget title={'Similar Products'}
                   products={visualSimilarityProducts}
                   breakpoints={{
                     mobile: 2,
                     tablet: 3,
                     desktop: 4,
                   }}/>

carouselGap - The gap between products in the carousel in pixel, default value is 16. For example:

  <FastSimonWidget title={'Similar Products'}
                   products={visualSimilarityProducts}
                   carouselGap={16}/>

RightArrowIcon - A JSX element to use as the right arrow icon in the carousel. For example:

  <FastSimonWidget title={'Similar Products'}
                   products={visualSimilarityProducts}
                   RightArrowIcon={<MyRightArrowIcon/>}/>

Don't worry about the left icon, we are rotating the icon automatically.

imageAspectRatio - The aspect ratio of the product image, default value is "2/3". For example:

  <FastSimonWidget title={'Similar Products'}
                   products={visualSimilarityProducts}
                   imageAspectRatio={"2/3"}/>

Consult the component documentation for more details on customization options.

For any issues, questions, or suggestions, please refer to the GitHub repository of @fast-simon/storefront-kit or contact our support team.