All questions

Best practice for adding the Hydrogen SDK to an established Remix-based storefront?

Asked by Omar El-Sayed on

OEOmar El-Sayed

We maintain a mature Hydrogen storefront on Remix, roughly two years of history, with existing request middleware for locale detection and some custom context plumbing. I am evaluating Croct and the docs point to the CLI for setup.

My concern is that CLI scaffolding tools are usually written for fresh projects. Is npx croct@latest init safe to run on an established codebase like ours, and what exactly does it change? I would rather know before it touches our entry files

Was this helpful?

1 answer

Croct Bot
AI
Accepted answer

Yes, the CLI is designed to work on existing projects, not only fresh ones. On a Hydrogen codebase, npx croct@latest init detects the existing setup, installs the SDK, and wires two things:

  1. The provider, so components can access the SDK.
  2. The request context, so content resolves per request inside your loaders.

It works on Remix-based Hydrogen as well as React Router 7, so your current framework is fully supported.

For a codebase with custom middleware and context plumbing, the practical advice is simple: run it on a clean branch and review the diff before merging. The changes are localized to the integration points above, and seeing them in version control is the fastest way to confirm nothing collides with your locale middleware.

To verify the integration afterwards, open the Integration page on the dashboard and check for the green "Received traffic in the past 24 hours" indicator. Details are in the Hydrogen SDK integration guide.

Was this helpful?
Still have questions?