What is the main goal of integrating Remix, GraphQL, and Hygraph?
The main goal is to build modern web applications that benefit from Remix's progressive enhancement and routing, GraphQL's flexible data querying, and Hygraph's headless CMS capabilities. This integration allows developers to fetch and manage structured content from Hygraph using GraphQL queries within Remix applications, enabling dynamic, scalable, and maintainable web projects.
How do you fetch data from Hygraph in a Remix application?
To fetch data from Hygraph in a Remix app, you use the graphql-request package along with Remix's loader functions. You set up a GraphQLClient with your Hygraph project endpoint and use GraphQL queries to retrieve content. The loader function runs on the server, fetches the data, and passes it to your React components via useLoaderData.
What packages are required to connect Remix with Hygraph via GraphQL?
You need to install graphql-request for making GraphQL queries and its peer dependency graphql. These packages allow you to create a GraphQL client and send queries to your Hygraph endpoint from within your Remix loaders.
How do you create dynamic routes in Remix to display content from Hygraph?
Dynamic routes in Remix are created by naming files with a $ prefix (e.g., products/$slug.jsx). In the loader function for these routes, you extract the dynamic parameter (like slug) from params and use it as a variable in your GraphQL query to fetch the corresponding content from Hygraph. The fetched data is then rendered in your component.
What is an example Hygraph GraphQL endpoint used in Remix integration?
An example Hygraph GraphQL endpoint is https://api-eu-central-1.hygraph.com/v2/ck8sn5tnf01gc01z89dbc7s0o/master. You use this endpoint with your GraphQL client to send queries and retrieve content for your Remix application. If your project is private, you need to provide an Authorization header with your API token.
How do you use GraphQL variables in Remix to fetch specific content from Hygraph?
You can use GraphQL variables in your queries by defining them in your query string (e.g., query ProductPageQuery($slug: String!)) and passing the variable (like slug) from the loader's params. This allows you to fetch specific entries, such as a product by its slug, from Hygraph.
Remix aims to encourage you to embrace natural progressive enhance with React, without having to make the tough decisions on whether something should be static, or server rendered, Remix "just works" where you want it to.
Last updated by Jamie
on Jun 12, 2026
Originally written by Jamie
on Nov 23, 2021
You have probably seen the news on the release of the anticipated Remix. Remix is a new framework focused on modern UX, and relies on tried and tested web fundamentals.
What does that mean? Remix aims to encourage you to embrace natural progressive enhancement with React, without having to make the tough decisions on whether something should be static, or server rendered, Remix "just works" where you want it to.
This content is provided by YouTube. Loading it sets cookies from YouTube.
We've been moving our frontend to the CDN for a few years now, and in some cases, waiting several hours for pages to be statically built too.
One of the newer approaches in static site generation is the idea of building pages on the fly, and caching them for some time, handling the regeneration at the edge. Some companies build their most popular landing pages ahead of time, while leaving the less popular ones to render on demand, cache, and revalidate (SWR).
The infrastructure behind server rendering traditional websites didn't go away while everyone was migrating to Static Site Generators either. If you've been working in the backend or serverless space, you've no doubt seen the breakthrough with services like Cloudflare Workers and Fastly Compute@Edge.
Remix does a lot of fancy stuff on the server for processing parallel requests, sending your complete page over the wire in one go, without the extra DOM bloat. If you've worked with frameworks like Laravel or Ruby on Rails, you will probably feel right at home.
Let's dive into how you can get started fetching from Hygraph inside your Remix app.
I'll imagine you're ahead of me with your Remix application running already. If not, follow the official docs on getting started.
We'll be using the following Hygraph project endpoint through the post, but you're welcome to follow along using your own. You'll need to provide an Authorization header with your API token if it's not public.
We'll be using the Remix loaders to fetch content for our pages. We could use the built in Fetch API, but let's use the package graphql-request that is a thin abstraction so we can set a client, pass variables, and catch any errors for us.
We'll also need to install the peer dependency graphql:
Inside of the app/routes folder, you'll want to create the index file. Let's call it index.jsx. If you're using TypeScript, it'll be .tsx. The sx extension is important!
Inside app/routes/index.jsx add import the hook useLoaderData, json, and Link:
import{ useLoaderData, json,Link}from"remix";
import{GraphQLClient, gql }from"graphql-request";
We'll now create a "Loader". This is core to Remix, and we can use it to fetch data from Hygraph using the GraphQLClient on the server.
Now all that's left to do is use export default to return our route component. For the sake of this post, we'll list all products from our query on the page, and Link to them:
Another typical use case when building a site is the ability to create pages with data from a database somewhere. This isn't a new concept, and thankfully with Hygraph, we can fetch those pages from the CMS.
In our example, we'll fetch a Product by slug that matches our page route.
We can use GraphQL variables to pass the slug of the current page to the query so we only fetch a single product content entry from Hygraph. The query looks like this:
constGetProductBySlug= gql`
query ProductPageQuery($slug: String!) {
product(where: { slug: $slug }) {
name
description
price
}
}
`;
Now, inside of the app/routes folder, create the folder/file products/$slug.jsx and add the following, along with the query, and loader for the page:
The loader here is doing similar to what we did on the index page; however, this time we're fetching params from the loader arguments, and from that we can access slug (it's slug because we named the file $slug.
Now, you just need to invoke the useLoaderData hook and create your page:
exportdefaultfunctionProductPage(){
let data =useLoaderData();
return(
<>
<h1>{data.product.name}</h1>
<p>{data.product.description}</p>
<p>{data.product.price/100}</p>
</>
);
}
Blog Author
Jamie Barton
Jamie is a software engineer turned developer advocate. Born and bred in North East England, he loves learning and teaching others through video and written tutorials. Jamie currently publishes Weekly GraphQL Screencasts.
Share with others
Sign up for our newsletter!
Be the first to know about releases and industry news and insights.
Remix aims to encourage you to embrace natural progressive enhance with React, without having to make the tough decisions on whether something should be static, or server rendered, Remix "just works" where you want it to.
Last updated by Jamie
on Jun 12, 2026
Originally written by Jamie
on Nov 23, 2021
You have probably seen the news on the release of the anticipated Remix. Remix is a new framework focused on modern UX, and relies on tried and tested web fundamentals.
What does that mean? Remix aims to encourage you to embrace natural progressive enhancement with React, without having to make the tough decisions on whether something should be static, or server rendered, Remix "just works" where you want it to.
This content is provided by YouTube. Loading it sets cookies from YouTube.
We've been moving our frontend to the CDN for a few years now, and in some cases, waiting several hours for pages to be statically built too.
One of the newer approaches in static site generation is the idea of building pages on the fly, and caching them for some time, handling the regeneration at the edge. Some companies build their most popular landing pages ahead of time, while leaving the less popular ones to render on demand, cache, and revalidate (SWR).
The infrastructure behind server rendering traditional websites didn't go away while everyone was migrating to Static Site Generators either. If you've been working in the backend or serverless space, you've no doubt seen the breakthrough with services like Cloudflare Workers and Fastly Compute@Edge.
Remix does a lot of fancy stuff on the server for processing parallel requests, sending your complete page over the wire in one go, without the extra DOM bloat. If you've worked with frameworks like Laravel or Ruby on Rails, you will probably feel right at home.
Let's dive into how you can get started fetching from Hygraph inside your Remix app.
I'll imagine you're ahead of me with your Remix application running already. If not, follow the official docs on getting started.
We'll be using the following Hygraph project endpoint through the post, but you're welcome to follow along using your own. You'll need to provide an Authorization header with your API token if it's not public.
We'll be using the Remix loaders to fetch content for our pages. We could use the built in Fetch API, but let's use the package graphql-request that is a thin abstraction so we can set a client, pass variables, and catch any errors for us.
We'll also need to install the peer dependency graphql:
Inside of the app/routes folder, you'll want to create the index file. Let's call it index.jsx. If you're using TypeScript, it'll be .tsx. The sx extension is important!
Inside app/routes/index.jsx add import the hook useLoaderData, json, and Link:
import{ useLoaderData, json,Link}from"remix";
import{GraphQLClient, gql }from"graphql-request";
We'll now create a "Loader". This is core to Remix, and we can use it to fetch data from Hygraph using the GraphQLClient on the server.
Now all that's left to do is use export default to return our route component. For the sake of this post, we'll list all products from our query on the page, and Link to them:
Another typical use case when building a site is the ability to create pages with data from a database somewhere. This isn't a new concept, and thankfully with Hygraph, we can fetch those pages from the CMS.
In our example, we'll fetch a Product by slug that matches our page route.
We can use GraphQL variables to pass the slug of the current page to the query so we only fetch a single product content entry from Hygraph. The query looks like this:
constGetProductBySlug= gql`
query ProductPageQuery($slug: String!) {
product(where: { slug: $slug }) {
name
description
price
}
}
`;
Now, inside of the app/routes folder, create the folder/file products/$slug.jsx and add the following, along with the query, and loader for the page:
The loader here is doing similar to what we did on the index page; however, this time we're fetching params from the loader arguments, and from that we can access slug (it's slug because we named the file $slug.
Now, you just need to invoke the useLoaderData hook and create your page:
exportdefaultfunctionProductPage(){
let data =useLoaderData();
return(
<>
<h1>{data.product.name}</h1>
<p>{data.product.description}</p>
<p>{data.product.price/100}</p>
</>
);
}
Blog Author
Jamie Barton
Jamie is a software engineer turned developer advocate. Born and bred in North East England, he loves learning and teaching others through video and written tutorials. Jamie currently publishes Weekly GraphQL Screencasts.
Share with others
Sign up for our newsletter!
Be the first to know about releases and industry news and insights.