Shopify Hydrogen / Remix

Environment Variables

Add the following to your .env file:

INTELLIGEMS_ORG_ID=<Intelligems-ID>
SHOPIFY_STOREFRONT_ACCESS_TOKEN=<Storefront-API-Token>

Vite Configuration

Add the intelligemsVitePlugin to your vite.config.ts plugins array. This plugin is required for the Intelligems Preview Mode widget to render and function correctly in Hydrogen apps. This plugin should be placed at the end / near the end of the plugins array, after the hydrogen and oxygen plugins.

Why is this needed?

The oxygen() Vite plugin from @shopify/mini-oxygen sets resolve.conditions to ["worker", "workerd"] globally, which causes client-side dependencies like @emotion/* and @mui/* to resolve server/edge build variants instead of browser builds. This breaks CSS injection and component interactivity in the Preview Mode widget.

The intelligemsVitePlugin moves these conditions to ssr.resolve.conditions where they belong, so that only server-side code uses worker builds while client-side code correctly resolves browser builds.

Is this safe?

The plugin has zero runtime cost — it runs once during Vite config resolution. Client-side code runs in the browser, not in a worker, so it should never have worker conditions applied. SSR behavior is completely unaffected since the worker conditions are preserved under ssr.resolve.conditions.

import { defineConfig } from "vite";
import { hydrogen } from "@shopify/hydrogen/vite";
import { oxygen } from "@shopify/mini-oxygen/vite";
import { vitePlugin as remix } from "@remix-run/dev";
import tsconfigPaths from "vite-tsconfig-paths";
import { intelligemsVitePlugin } from "@intelligems/headless/hydrogen";

export default defineConfig({
  plugins: [
    hydrogen(),
    oxygen(),
    remix({
      presets: [hydrogen.preset()],
      future: {
        v3_fetcherPersist: true,
        v3_relativeSplatPath: true,
        v3_throwAbortReason: true,
        v3_lazyRouteDiscovery: true,
      },
    }),
    tsconfigPaths(),
    intelligemsVitePlugin(),
  ],
  ssr: {
    optimizeDeps: {
      include: ["@intelligems/headless/hydrogen"],
    },
  },
});

loader() Configuration

Update the loader() function to pre-load the Intelligems configuration. Optionally pass in a cache interval (in minutes).

Provider Integration

The IntelligemsHydrogenProvider component stores Intelligems data in React Context so hooks and components can access it throughout your app.

Page Views Tracking

useIgTrack is a client-side hook tracking page views.

To provide accurate analytics ensure it is configured with valid parameters:

  • cartOrCheckoutToken

  • currency

  • country

Last updated