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/shopify-hydrogen

v1.0.4

Published

Build Search and Discovery experience with Fast Simon, a Shopify Plus Certified Partner

Downloads

3

Readme

Fast Simon & Shopify Integration

Build Search and Discovery experience with Fast Simon, a Shopify Plus Certified Partner

Getting started guide

Hydrogen App

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

Getting started guide

Fast Simon For Shopify Hydrogen

React NPM package to support Fast Simon Search and Discovery tools in Shopify Hydrogen Projects.

What is Fast Simon for Shopify Hydrogen?

Fast Simon Shopify Hydrogen is a React library to be used in Shopify Hydrogen apps.

By installing this library on your Hydrogen-based React Shopify storefront, you will be able to render Fast Simon Search and Discovery tools in your app.

Installation Guide

This document will guide you to:

  • Configure your Shopify store ready for Fast Simon Shopify Hydrogen.
  • Install and use Fast Simon Shopify Hydrogen components in your Shopify Hydrogen app.

Requirements

  • Shopify store
  • Hydrogen app
  • Fast Simon app installed on your Shopify store
  • Shopify custom app with Storefront access token

Configure Hydrogen app config

Update hydrogen.config.js with your shop's domain and Storefront API token.

Expose Shopify Metafields

Fast Simon Search and Discovery uses Metafields in order to customize the UI based on Fast Simon No-code editor configuration. Metafields need to be exposed so that they can be retrieved by your Hydrogen app.

Unfortunately, Shopify does not have a way of exposing Shop Metafields via their admin UI.

We strongly recommend to contact Fast Simon Support, we will expose the relevant Metafields for you.

How to Use Fast Simon In Your Hydrogen App

Installation

  1. In your Hydrogen app directory, run
npm install @fast-simon/shopify-hydrogen
  1. Create fastsimon.config.json file in your root directory and fill it with your Fast Simon UUID & store id:
{
    "UUID": "",
    "storeID": 0
}
  1. Open vite.config.ts and import the Fast Simon plugin:
import fastSimonPlugin from "@fast-simon/shopify-hydrogen/plugin";
  1. Add fastSimon()to the list of plugins:
  /// <reference types="vitest" />
  import {defineConfig} from 'vite';
  import hydrogen from '@shopify/hydrogen/plugin';
  import fastSimonPlugin from "@fast-simon/shopify-hydrogen/plugin";
  
  export default defineConfig({
      plugins: [hydrogen(), fastSimonPlugin()],
      resolve: {
          alias: [{find: /^~\/(.*)/, replacement: '/src/$1'}],
      },
      optimizeDeps: {
          include: ['@headlessui/react', 'clsx', 'react-use', 'typographic-base'],
      },
      test: {
          globals: true,
          testTimeout: 10000,
          hookTimeout: 10000,
      },
      server: {
          port: 5000
      },
  });
  1. Open App.server.tsx and import FastSimonProviderServer:
import fastSimonPlugin from "@fast-simon/shopify-hydrogen/plugin";
  1. Include the FastSimonProviderServer, passing through the request object, UUID and store id from your fastsimon.config.json file:
  function App({request}) {
      const pathname = new URL(request.normalizedUrl).pathname;
      const localeMatch = /^\/([a-z]{2})(\/|$)/i.exec(pathname);
      const countryCode = localeMatch ? localeMatch[1] : undefined;
      const isHome = pathname === `/${countryCode ? countryCode + '/' : ''}`;
  
      return (
          <Suspense fallback={<HeaderFallback isHome={isHome} />}>
              <ShopifyProvider countryCode={countryCode}>
                  <FastSimonProviderServer storeID={fastConfig.storeID} uuid={fastConfig.UUID} request={request}>
                      <CartProvider countryCode={countryCode}>
                          <Suspense>
                              <DefaultSeo />
                          </Suspense>
                          <Router>
                              <FileRoutes
                                  basePath={countryCode ? `/${countryCode}/` : undefined}
                              />
                              <Route path="*" page={<NotFound />} />
                          </Router>
                      </CartProvider>
                      <PerformanceMetrics />
                      {import.meta.env.DEV && <PerformanceMetricsDebug />}
                      <ShopifyAnalytics />
                  </FastSimonProviderServer>
              </ShopifyProvider>
          </Suspense>
      );
  }

You can also provide your UUID and storeID directly instead of creating the fastsimon.config.json

Usage

Collections:
  1. Open src/routes/collections/[handle].server.jsx and import FastSimonAppServer:
import {FastSimonAppServer} from "@fast-simon/shopify-hydrogen";
  1. To the collection handler function, add fastSimonProps parameter:
export default function Collection({params, fastSimonProps}) {...}
  1. Replace the Shopify Grid component by FastSimonAppServer, pass collectionID and fastSimonProps as shown below.
    <Layout>
        <Suspense>
            <Seo type="collection" data={collection} />
        </Suspense>
        <PageHeader heading={collection.title}>
            {collection?.description && (
                <div className="flex items-baseline justify-between w-full">
                    <div>
                        <Text format width="narrow" as="p" className="inline-block">
                            {collection.description}
                        </Text>
                    </div>
                </div>
            )}
        </PageHeader>
        <Section>
            <FastSimonAppServer collectionID={collection.id} fastSimonProps={fastSimonProps}/>
        </Section>
    </Layout>
Search Page:
  1. Open src/routes/search.server.jsx and import FastSimonAppServer:
import {FastSimonAppServer} from "@fast-simon/shopify-hydrogen";
  1. To the search handler function, add fastSimonProps parameter:
export default function Search({pageBy = PAGINATION_SIZE, params, fastSimonProps}) {...}
  1. Replace the Shopify Grid component by FastSimonAppServer, pass query and fastSimonProps as shown below.
  return (
    <SearchPage searchTerm={decodeURI(searchTerm)}>
        <Section>
            <FastSimonAppServer query={decodeURI(searchTerm)} fastSimonProps={fastSimonProps}/>
        </Section>
    </SearchPage>
);