Skip to content

Sanity and Hydrogen v2 #530

Answered by juanpprieto
Makxzod asked this question in Help
Discussion options

You must be logged in to vote

Hi @carstensbix thanks for stopping by.

While we release examples, I suggest you take a look at how we create and embed the storefront API client inside the remix context. Here's an approach you could pursue:

  1. Creating the client instance
    const {storefront} = createStorefrontClient({
// server.ts
const sanityClient = sanityClient(sanityConfig);
async function sanity<T>(query, params = {}): <T> {
 return await client.fetch(query, params)
}
  1. Expose the client to the context, so that it is available in all loaders and actions
    getLoadContext: () =>

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Makxzod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants