How do I set up Preview Mode with Remix and Hygraph?
To set up Preview Mode, you need to configure your Remix application to use Hygraph's GraphQL API with environment-based tokens. You create a dedicated API route (e.g., /api/preview) that validates a secret and a slug, sets a cookie to enable preview mode, and redirects to the draft content. The loader functions in your Remix routes should check for this cookie to determine whether to use the draft or published API token. For a full walkthrough, see the official tutorial and the GitHub source code. Note: You must manage environment variables and cookies correctly for preview mode to function.
What are the requirements for integrating Hygraph with Remix?
You need a Hygraph project (which you can clone from the provided starter), a Remix application (created via npx create-remix@latest), and the graphql-request client. You must set up environment variables for your Hygraph endpoint and API tokens, and configure your routes to use these tokens based on preview mode status. For rendering rich text, install @hygraph/rich-text-react-renderer and @hygraph/rich-text-types. Note: Proper permissions and token management are required for accessing draft and published content.
How does preview mode work in a Hygraph + Remix application?
Preview mode is enabled by setting a cookie when a valid secret and slug are provided to a dedicated API route. When preview mode is active, your Remix loaders use the draft API token to fetch unpublished content. A visual banner can be displayed to indicate preview mode is active. Exiting preview mode resets the cookie and returns the user to published content. Note: If cookies are not set or the secret is invalid, preview mode will not activate.
What are the limitations of using preview mode with Hygraph and Remix?
Preview mode requires careful management of environment variables, API tokens, and cookies. If cookies are blocked or not set correctly, preview mode will not function. Additionally, parent routes in Remix may not reload data unless a form action is used to exit preview mode, which can affect navigation and content updates. Detailed limitations not publicly documented; ask sales or consult the Hygraph documentation for specifics.
Features & Capabilities
What APIs does Hygraph provide for developers?
Hygraph offers several APIs: the GraphQL Content API for querying and manipulating content, the Management API for handling project structure, the Asset Upload API for uploading files, and the MCP Server API for secure AI assistant communication. For details, see the API Reference documentation. Note: Some APIs require specific permissions and tokens for access.
What integrations are available with Hygraph?
Hygraph integrates with a range of platforms, including Digital Asset Management (DAM) systems like Aprimo, AWS S3, Bynder, Cloudinary, Imgix, Mux, and Scaleflex Filerobot; hosting providers like Netlify and Vercel; Product Information Management (PIM) with Akeneo; commerce solutions like BigCommerce; and translation/localization with EasyTranslate. For a full list, visit the Hygraph Marketplace. Note: Integration availability may depend on your plan and project setup.
What technical documentation is available for Hygraph users?
Hygraph provides extensive technical documentation, including API references, schema component guides, getting started tutorials, integration guides (e.g., Mux, Akeneo, Auth0), and AI feature documentation. Access all resources at hygraph.com/docs. Note: Documentation for Hygraph Classic is also available for legacy users.
What performance optimizations does Hygraph offer?
Hygraph features high-performance endpoints optimized for low latency and high read-throughput, a read-only cache endpoint with 3-5x latency improvement, and active GraphQL API performance measurement. For more, see the performance improvements blog post and the GraphQL Report 2024. Note: Actual performance may vary based on usage and configuration.
Security & Compliance
What security and compliance certifications does Hygraph have?
Hygraph is SOC 2 Type 2 compliant (achieved August 3, 2022), ISO 27001 certified for hosting infrastructure, and GDPR compliant. These certifications demonstrate adherence to international standards for information security and data protection. For more, see the Secure Features page. Note: Certification scope may vary by deployment region and infrastructure.
What security features are available in Hygraph?
Hygraph provides granular permissions, SSO integrations (OIDC/LDAP/SAML), audit logs, encryption in transit and at rest, regular backups with one-click recovery, and secure API policies (custom origin policies and IP firewalls). All endpoints have SSL certificates. For more, visit the Secure Features page. Note: Some features may require enterprise plans or additional configuration.
Use Cases & Implementation
Who can benefit from using Hygraph?
Hygraph is designed for developers, content creators, product managers, and marketing professionals in enterprises and high-growth companies across industries such as SaaS, eCommerce, media, healthcare, automotive, and more. It is suitable for teams needing advanced content management, localization, and integration capabilities. Note: Teams with highly specialized legacy systems may require additional migration planning.
How long does it take to implement Hygraph?
Implementation time varies by project complexity. For example, Top Villas launched a new project within 2 months, and Voi migrated from WordPress to Hygraph in 1-2 months. Starter projects and structured onboarding are available to accelerate adoption. Note: Large-scale migrations or highly customized workflows may require additional time.
What business impact can customers expect from using Hygraph?
Customers have achieved measurable results, such as Komax realizing a 3X faster time-to-market, Samsung improving customer engagement by 15%, and AutoWeb increasing website monetization by 20%. Hygraph supports faster launches, improved content consistency, and cost reduction. For more, see Hygraph case studies. Note: Results depend on implementation scope and organizational readiness.
What pain points does Hygraph address for content teams?
Hygraph helps reduce developer dependency, modernize legacy tech stacks, ensure content consistency across regions, streamline workflows, lower operational costs, accelerate speed-to-market, and simplify schema evolution. It also addresses integration difficulties and performance bottlenecks. Note: Some pain points, such as highly specialized legacy integrations, may require custom solutions.
Customer Proof & Success Stories
What feedback have customers given about Hygraph's ease of use?
Customers have praised Hygraph for its intuitive interface, quick adaptability, and accessibility for non-technical users. For example, Sigurður G. (CTO) noted the UI is intuitive, and Charissa K. (Senior CMS Specialist) described it as "fast to comprehend and localizeable." Multiple reviews highlight the ease of setup and granular roles/permissions. Note: Some advanced features may require developer involvement for initial setup.
Can you share specific case studies or customer success stories using Hygraph?
Yes. Notable examples include Samsung (15% improved customer engagement), Komax (3X faster time-to-market), AutoWeb (20% increase in website monetization), Voi (scaled multilingual content across 12 countries), and HolidayCheck (reduced developer bottlenecks). See more at Hygraph case studies. Note: Outcomes vary by project and implementation.
Industries & Use Cases
What industries are represented in Hygraph's case studies?
Hygraph is used in SaaS, marketplaces, education technology, media and publication, healthcare, consumer goods, automotive, technology, fintech, travel and hospitality, food and beverage, eCommerce, agencies, online gaming, events & conferences, government, consumer electronics, engineering, and construction. For details, see case studies. Note: Industry-specific requirements may affect implementation details.
How to Create a Preview Mode with Remix and Hygraph
In this example, we will show you how to create and initialize a Preview Mode for your content using Remix and Hygraph.
Last updated by João
on Jan 21, 2026
Originally written by João
We’ve been using Next.js for a long time here at Hygraph and one of the features we love the most in Next is preview mode. It allows you to write a draft on your headless CMS and preview it immediately on your website.
In February, we released the new Hygraph Docs Starter, which allows you to create and manage documentation for your business, product, and services. The starter is built with Remix, TypeScript, GraphQL, and styled with TailwindCSS.
We chose Remix for the docs starter, as it is a Full stack web framework that focuses on the web fundamentals with an edge-first approach, without sacrificing a modern UX. We also wanted to try and use it on a real-world project.
After releasing the starter and using it, we added preview mode support for it, so content editors could quickly preview the changes, without needing to publish.
In this guide, you’ll learn how to set up a Remix application, fetch data from a GraphQL API, and configure a preview mode on the app with Hygraph.
Want to try the application before following the tutorial? See the demo. To test preview mode, click here.
The easiest way to create a Remix application is by using the CLI.
npx create-remix@latest
The CLI will prompt a few questions, regarding the folder where you want to create your app, the type, and a few other things.
The only elements that are important for us in this tutorial is the type of the app, and if you want to use TypeScript or JavaScript. Make sure to select the option “Just the basics”, and also TypeScript.
…
? What type of app do you want to create? Just the basics
Since the focus here is on Remix and setting up preview mode, we won’t create a big project on Hygraph. The application we’ll build is a news website, with a page to see all the news and a dynamic route to see the news itself.
To create the Hygraph project, you can use the clone button below.
To simplify the tutorial, we’ll use graphql-request, which is a straightforward GraphQL client created and maintained by our friends from Prisma.
On the Docs Starter, we decided to use [GraphQL Code Generator](https://www.graphql-code-generatoHow r.com/), which is also a powerful but simple library, created by The Guild.
Let’s get started by installing the packages.
npm add graphql-request graphql
Now, let’s create a folder named lib inside app. In the lib folder, create a file named hygraph.server.ts. This file will export the GraphQL client, with the Hygraph endpoint.
On the file we created, we’ll use a HYGRAPH_ENDPOINT environment variable, which is the endpoint of our GraphQL API.
The remix dev server provides built-in support for environment variables during development, but you’ll need to configure them on your server. For more information, I recommend checking the Remix documentation.
To add the environment variable, create a .env file on the root.
touch .env
And edit the file:
HYGRAPH_ENDPOINT=
You can find the Hygraph endpoint on Project Settings -> API Access -> Content API
If you already started your server, you’ll need to restart it.
Before focusing on preview mode, let’s update the index page, so it can show all the articles. The first thing we need to do is define a "loader" function that will be called on the server before rendering to provide data.
// app/routes/index.tsx
import type { LoaderFunction } from "@remix-run/node";
Inside the loader function, we need to use the GraphQL client instance to send a request. We also need to define our query that will fetch all the articles.
// app/routes/index.tsx
import type { LoaderFunction } from '@remix-run/node';
const data = await hygraph.request(allArticlesQuery);
return json({
articles: data.articles,
});
};
// …
The API will return an object with all the articles. Since all loaders must return a Response object, we can use the json function to convert the object into a JSON response. We will now use this data on our page.
If you start your server using npm run dev and go to [http://localhost:3000](http://localhost:3000), you’ll see: an error! 😔
That error occurs because we haven’t defined the permissions for our API. On the ‘API Access’ page on Hygraph, go to the ‘Permanent Auth Tokens’ section, and create a new token for development. The default stage will be Draft.
On the token page, in the content permissions section, you also need to initialize the default permissions.
We will also need a production token. The process to create it is the same, but the default stage must be Published.
After creating both tokens, we need to add two new environment variables to the .env file.
# .env
HYGRAPH_ENDPOINT=<api-url>
HYGRAPH_DEV_TOKEN=
HYGRAPH_PROD_TOKEN=
The last step is updating the index.tsx loader function.
You may notice that we’re defining a preview variable as ‘true’, which controls which token we’re using. Later, we’ll implement the logic to check if we’re in preview or not, but for now, we’ll keep it this way.
Now, if you refresh the page, you’ll see all the articles. 🎉
Now that the ‘index page’ is ready, we can start working on the ‘article page’. First, we need to define a dynamic route, because we don’t want to create new files for every new article. On Remix, routes that begin with a $ character indicate that the route is dynamic. So, let’s create a file named $slug.tsx in the routes folder. Below, you can find the complete code for the page.
// app/routes/$slug.tsx
import type { LoaderFunction } from '@remix-run/node';
The logic for this page is almost the same as the index route, but with a few differences.
On our GraphQL query, we define a $url variable, so we can filter the article based on it;
On the loader, to get the $slug value, we can use the params parameter, which is available in the loader function.
Rendering Rich Text content
The only thing missing on the ‘article page’ is rendering the Rich Text content. Luckily, that’s an easy task. Hygraph has a Rich Text Renderer library for React, which handles everything out of the box.
First, let’s install the package.
npm add @hygraph/rich-text-react-renderer
We also need to install the types.
npm add @hygraph/rich-text-types -D
Inside the article page, we need to update the Article type, and use the RichText component which was exported from the @hygraph/rich-text-react-renderer package.
// …
import { RichText } from '@hygraph/rich-text-react-renderer';
import type { ElementNode } from '@hygraph/rich-text-types';
With the project ready, we can now start the preview mode logic. On both pages, we’re controlling the token based on a variable, which is set as true. However, what we really need to do is control preview mode based on a cookie. Lucily, that’s super easy to do with Remix. Before getting started, let’s understand how it will work.
With Hygraph, we can define Preview URLs for every schema. For our project, we only want to do that on the Article schema. The configuration for preview links looks like this:
Let’s break it into parts. First, you’ll see that we have two preview links configurations, one for production, which we call “Preview”, and the other one for Development. The only difference between these two are the URL, but the structure will always be similar to this:
<secret> should be replaced with a secret token. Only your app and Hygraph will know this secret.
<slug> should be the path for the page that you want to preview. On Hygraph, you can use all the schema fields.
This route api/preview, will be responsible for checking if the secret matches with the one you have on your app, and it also needs to check if that slug exists in the CMS, otherwise the request should fail.
If the secret is valid and there’s a slug, we’ll set a cookie. Any requests containing this cookie on the article or index page will be considered preview mode. The token used on the API request changes, which allows us to see draft content on the app.
To get started, create a folder under routes named api and a file preview.ts inside it. This route is the one we also configured on the CMS.
In this file, we’re fetching the search params, checking if the secret matches an environment variable, and looking for the article on the CMS. If it exists, we need to set a cookie.
Remember to add the PREVIEW_SECRET on the .env file. You also need to restart your server.
Working with Cookies
To get started, create a file preview-mode.server.ts under a folder named utils. The first thing we need to do within this file is create a cookie and with Remix, that’s very easy.
The createCookie function exported from @remix-run/node package receives the cookie name as the first argument, and the cookie attributes as the second argument. You can find the complete list of cookie attributes on MDN.
As a plus, you could also define a maxAge attribute in seconds, which specifies the duration for the preview cookie to last for.
Continuing, create another file on the utils folder named parse-cookie.server.ts. This file will have only one responsibility: parsing a cookie received as an argument.
If you are in preview mode in the current state of the application, you won’t get any visual feedback on the application saying that you’re seeing draft content. That not ideal from a UX perspective. We also need to check on the loader function, on both pages (article and index), if we’re really in preview mode. Right now, we’re controlling that based on a variable, which is set as true.
First, let’s create a function to check if we are in preview mode. Go to the preview-mode.server.ts file, and add the following function:
With the isPreviewMode function in place, we can now use it on the article and index page. The first thing we need to do is import the function, and use it on the loader. We are also going to return a isInPreview variable from the loader, so we can use it on the page to show a banner, which we will create later.
Let’s start by changing the article page.
// app/routes/$slug.tsx
// …
import { isPreviewMode } from '~/utils/preview-mode.server';
import { PreviewBanner } from '~/components/preview-banner';
If you try the preview mode, you should see the banner on the page.
But you might be wondering, why are we using a <form> to exit preview mode, and not a link to an API route, like on Next.js?
Remix has a different approach when compared to Next.js, especially when we are talking about layouts and routes. When we have a parent route on our application, like a layout route, with a header where all the items are requested from the CMS, Remix will only load the data for the parts of the page that are changing on navigation.
If you click a link in the header Remix knows that the parent route will remain on the page but the child route's data will change because the url param for the document will change. With this insight, Remix will not refetch the parent route's data. To force a full reload, we can use an action, and that’s exactly what we are doing here.
This application doesn’t have any parent routes. However, if we take the docs starter for example, all the sidebar entries are coming from the CMS. When you enter preview mode, the items from the navigation will also update and show draft changes. If we use a link to exit, the parent route won’t change, and the navigation will still show the draft content until you reload. If you want to dive deeper, I recommend taking a look into this guide.
Exit Preview Mode
The last thing we need to do on our app is implementing the exit preview API route. This is very simple since the only thing it needs to do is change the cookie value and redirect to the homepage.
On the route, we also need to make sure to have a loader function, which redirects to the homepage, in case someone tries to access the route directly.
—
See all the changes we did on this preview mode section here.
—
I hope this post has helped you getting started with Remix and Hygraph, and setting up preview mode. The source code is available on GitHub. If you have any questions, make sure to post them to our community on Slack!
Blog Author
João Pedro Schmitz
Front-End Engineer
Front-End Engineer in love with React. Learning every day.
Share with others
Sign up for our newsletter!
Be the first to know about releases and industry news and insights.
How to Create a Preview Mode with Remix and Hygraph
In this example, we will show you how to create and initialize a Preview Mode for your content using Remix and Hygraph.
Last updated by João
on Jan 21, 2026
Originally written by João
We’ve been using Next.js for a long time here at Hygraph and one of the features we love the most in Next is preview mode. It allows you to write a draft on your headless CMS and preview it immediately on your website.
In February, we released the new Hygraph Docs Starter, which allows you to create and manage documentation for your business, product, and services. The starter is built with Remix, TypeScript, GraphQL, and styled with TailwindCSS.
We chose Remix for the docs starter, as it is a Full stack web framework that focuses on the web fundamentals with an edge-first approach, without sacrificing a modern UX. We also wanted to try and use it on a real-world project.
After releasing the starter and using it, we added preview mode support for it, so content editors could quickly preview the changes, without needing to publish.
In this guide, you’ll learn how to set up a Remix application, fetch data from a GraphQL API, and configure a preview mode on the app with Hygraph.
Want to try the application before following the tutorial? See the demo. To test preview mode, click here.
The easiest way to create a Remix application is by using the CLI.
npx create-remix@latest
The CLI will prompt a few questions, regarding the folder where you want to create your app, the type, and a few other things.
The only elements that are important for us in this tutorial is the type of the app, and if you want to use TypeScript or JavaScript. Make sure to select the option “Just the basics”, and also TypeScript.
…
? What type of app do you want to create? Just the basics
Since the focus here is on Remix and setting up preview mode, we won’t create a big project on Hygraph. The application we’ll build is a news website, with a page to see all the news and a dynamic route to see the news itself.
To create the Hygraph project, you can use the clone button below.
To simplify the tutorial, we’ll use graphql-request, which is a straightforward GraphQL client created and maintained by our friends from Prisma.
On the Docs Starter, we decided to use [GraphQL Code Generator](https://www.graphql-code-generatoHow r.com/), which is also a powerful but simple library, created by The Guild.
Let’s get started by installing the packages.
npm add graphql-request graphql
Now, let’s create a folder named lib inside app. In the lib folder, create a file named hygraph.server.ts. This file will export the GraphQL client, with the Hygraph endpoint.
On the file we created, we’ll use a HYGRAPH_ENDPOINT environment variable, which is the endpoint of our GraphQL API.
The remix dev server provides built-in support for environment variables during development, but you’ll need to configure them on your server. For more information, I recommend checking the Remix documentation.
To add the environment variable, create a .env file on the root.
touch .env
And edit the file:
HYGRAPH_ENDPOINT=
You can find the Hygraph endpoint on Project Settings -> API Access -> Content API
If you already started your server, you’ll need to restart it.
Before focusing on preview mode, let’s update the index page, so it can show all the articles. The first thing we need to do is define a "loader" function that will be called on the server before rendering to provide data.
// app/routes/index.tsx
import type { LoaderFunction } from "@remix-run/node";
Inside the loader function, we need to use the GraphQL client instance to send a request. We also need to define our query that will fetch all the articles.
// app/routes/index.tsx
import type { LoaderFunction } from '@remix-run/node';
const data = await hygraph.request(allArticlesQuery);
return json({
articles: data.articles,
});
};
// …
The API will return an object with all the articles. Since all loaders must return a Response object, we can use the json function to convert the object into a JSON response. We will now use this data on our page.
If you start your server using npm run dev and go to [http://localhost:3000](http://localhost:3000), you’ll see: an error! 😔
That error occurs because we haven’t defined the permissions for our API. On the ‘API Access’ page on Hygraph, go to the ‘Permanent Auth Tokens’ section, and create a new token for development. The default stage will be Draft.
On the token page, in the content permissions section, you also need to initialize the default permissions.
We will also need a production token. The process to create it is the same, but the default stage must be Published.
After creating both tokens, we need to add two new environment variables to the .env file.
# .env
HYGRAPH_ENDPOINT=<api-url>
HYGRAPH_DEV_TOKEN=
HYGRAPH_PROD_TOKEN=
The last step is updating the index.tsx loader function.
You may notice that we’re defining a preview variable as ‘true’, which controls which token we’re using. Later, we’ll implement the logic to check if we’re in preview or not, but for now, we’ll keep it this way.
Now, if you refresh the page, you’ll see all the articles. 🎉
Now that the ‘index page’ is ready, we can start working on the ‘article page’. First, we need to define a dynamic route, because we don’t want to create new files for every new article. On Remix, routes that begin with a $ character indicate that the route is dynamic. So, let’s create a file named $slug.tsx in the routes folder. Below, you can find the complete code for the page.
// app/routes/$slug.tsx
import type { LoaderFunction } from '@remix-run/node';
The logic for this page is almost the same as the index route, but with a few differences.
On our GraphQL query, we define a $url variable, so we can filter the article based on it;
On the loader, to get the $slug value, we can use the params parameter, which is available in the loader function.
Rendering Rich Text content
The only thing missing on the ‘article page’ is rendering the Rich Text content. Luckily, that’s an easy task. Hygraph has a Rich Text Renderer library for React, which handles everything out of the box.
First, let’s install the package.
npm add @hygraph/rich-text-react-renderer
We also need to install the types.
npm add @hygraph/rich-text-types -D
Inside the article page, we need to update the Article type, and use the RichText component which was exported from the @hygraph/rich-text-react-renderer package.
// …
import { RichText } from '@hygraph/rich-text-react-renderer';
import type { ElementNode } from '@hygraph/rich-text-types';
With the project ready, we can now start the preview mode logic. On both pages, we’re controlling the token based on a variable, which is set as true. However, what we really need to do is control preview mode based on a cookie. Lucily, that’s super easy to do with Remix. Before getting started, let’s understand how it will work.
With Hygraph, we can define Preview URLs for every schema. For our project, we only want to do that on the Article schema. The configuration for preview links looks like this:
Let’s break it into parts. First, you’ll see that we have two preview links configurations, one for production, which we call “Preview”, and the other one for Development. The only difference between these two are the URL, but the structure will always be similar to this:
<secret> should be replaced with a secret token. Only your app and Hygraph will know this secret.
<slug> should be the path for the page that you want to preview. On Hygraph, you can use all the schema fields.
This route api/preview, will be responsible for checking if the secret matches with the one you have on your app, and it also needs to check if that slug exists in the CMS, otherwise the request should fail.
If the secret is valid and there’s a slug, we’ll set a cookie. Any requests containing this cookie on the article or index page will be considered preview mode. The token used on the API request changes, which allows us to see draft content on the app.
To get started, create a folder under routes named api and a file preview.ts inside it. This route is the one we also configured on the CMS.
In this file, we’re fetching the search params, checking if the secret matches an environment variable, and looking for the article on the CMS. If it exists, we need to set a cookie.
Remember to add the PREVIEW_SECRET on the .env file. You also need to restart your server.
Working with Cookies
To get started, create a file preview-mode.server.ts under a folder named utils. The first thing we need to do within this file is create a cookie and with Remix, that’s very easy.
The createCookie function exported from @remix-run/node package receives the cookie name as the first argument, and the cookie attributes as the second argument. You can find the complete list of cookie attributes on MDN.
As a plus, you could also define a maxAge attribute in seconds, which specifies the duration for the preview cookie to last for.
Continuing, create another file on the utils folder named parse-cookie.server.ts. This file will have only one responsibility: parsing a cookie received as an argument.
If you are in preview mode in the current state of the application, you won’t get any visual feedback on the application saying that you’re seeing draft content. That not ideal from a UX perspective. We also need to check on the loader function, on both pages (article and index), if we’re really in preview mode. Right now, we’re controlling that based on a variable, which is set as true.
First, let’s create a function to check if we are in preview mode. Go to the preview-mode.server.ts file, and add the following function:
With the isPreviewMode function in place, we can now use it on the article and index page. The first thing we need to do is import the function, and use it on the loader. We are also going to return a isInPreview variable from the loader, so we can use it on the page to show a banner, which we will create later.
Let’s start by changing the article page.
// app/routes/$slug.tsx
// …
import { isPreviewMode } from '~/utils/preview-mode.server';
import { PreviewBanner } from '~/components/preview-banner';
If you try the preview mode, you should see the banner on the page.
But you might be wondering, why are we using a <form> to exit preview mode, and not a link to an API route, like on Next.js?
Remix has a different approach when compared to Next.js, especially when we are talking about layouts and routes. When we have a parent route on our application, like a layout route, with a header where all the items are requested from the CMS, Remix will only load the data for the parts of the page that are changing on navigation.
If you click a link in the header Remix knows that the parent route will remain on the page but the child route's data will change because the url param for the document will change. With this insight, Remix will not refetch the parent route's data. To force a full reload, we can use an action, and that’s exactly what we are doing here.
This application doesn’t have any parent routes. However, if we take the docs starter for example, all the sidebar entries are coming from the CMS. When you enter preview mode, the items from the navigation will also update and show draft changes. If we use a link to exit, the parent route won’t change, and the navigation will still show the draft content until you reload. If you want to dive deeper, I recommend taking a look into this guide.
Exit Preview Mode
The last thing we need to do on our app is implementing the exit preview API route. This is very simple since the only thing it needs to do is change the cookie value and redirect to the homepage.
On the route, we also need to make sure to have a loader function, which redirects to the homepage, in case someone tries to access the route directly.
—
See all the changes we did on this preview mode section here.
—
I hope this post has helped you getting started with Remix and Hygraph, and setting up preview mode. The source code is available on GitHub. If you have any questions, make sure to post them to our community on Slack!
Blog Author
João Pedro Schmitz
Front-End Engineer
Front-End Engineer in love with React. Learning every day.
Share with others
Sign up for our newsletter!
Be the first to know about releases and industry news and insights.