Hydrogen 2.0 Remix Loader Query
// Shopify Hydrogen 2.0 Remix Route Loader Function
import { json, type LoaderFunctionArgs } from '@shopify/remix-oxygen';
export async function loader({ context, params }: LoaderFunctionArgs) {
const { handle } = params;
const { product } = await context.storefront.query(PRODUCT_QUERY, {
variables: { handle },
});
if (!product) throw new Response('Not Found', { status: 404 });
return json({ product });
}
Suggested & Related Reading
Explore related engineering guides from Kenneth D'Silva:
-
Custom Shopify App Development
GraphQL Admin API integrations with Remix.
-
Headless Architecture: Why Decoupling Front-End Unlocks Speed & SEO
Comparison between monolithic and headless storefronts.