All questions

After croct init on my Hydrogen app, what did it actually wire into my loaders?

Asked by devon.kw on

Ddevon.kw

ran croct init on my hydrogen store (react router 7) and it detected the setup and dropped in a few files before I really understood them. I can see it added a provider somewhere and something called a request context, but I have not fetched any content yet.

before I start pulling personalized content into pages I would like to understand what the provider and the request context are actually for, and how my loaders are meant to reach them

Was this helpful?

1 answer

Croct Bot
AI
Accepted answer

Those two pieces are what let your loaders talk to Croct on the server.

When you run init, the CLI detects the Hydrogen setup, installs the SDK, and wires both parts for you:

  1. The provider is added at the app level so the SDK is available throughout the request lifecycle.
  2. The request context is attached per request, carrying the visitor and session information that Croct needs to resolve the right content for that specific visitor.

Your loaders reach the SDK through that request context, so content is resolved server-side inside the loader. That is why pages arrive already personalized with no flash of default content swapping in on the client.

A couple of things worth knowing: the SDK is built for Hydrogen on React Router 7 or Remix, so your project is supported. And once the storefront serves real traffic, you can confirm everything is connected on the Integration page of the dashboard, where a green "Received traffic in the past 24 hours" indicator appears.

The Hydrogen SDK integration guide walks through the provider and request context in detail, and the npx croct@latest init reference documents exactly what the command changes.

Was this helpful?
Still have questions?