Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion skills/sanity-best-practices/references/hydrogen.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ import {createSanityContext, type SanityContext} from 'hydrogen-sanity'
import {PreviewSession} from 'hydrogen-sanity/preview/session'
import {isPreviewEnabled} from 'hydrogen-sanity/preview'

const previewSession = await PreviewSession.init(request, [env.SESSION_SECRET])

const sanity = await createSanityContext({
request,
cache,
Expand Down Expand Up @@ -124,7 +126,7 @@ const PRODUCT_QUERY = defineQuery(`*[_type == "product" && store.slug.current ==

// Loader
export async function loader({params, context: {sanity}}: LoaderFunctionArgs) {
const initial = await context.sanity.query(PRODUCT_QUERY, params)
const initial = await sanity.query(PRODUCT_QUERY, params)
return {initial}
}

Expand Down