<p>In my <a href="https://www.trevor-davis.com/blog/why-im-so-excited-about-remix">previous post</a>, I talked about transitioning my site from being powered by <a href="https://craftcms.com/">Craft</a> to being powered by <a href="https://remix.run/">Remix</a> and a GraphQL endpoint coming from Craft. One of the best features of Craft is <a href="https://craftcms.com/features/all#live-preview">Live Preview</a>, and it took a little configuration to get this working on my new Remix powered site.</p>
<h2>Remix Configuration</h2>
<p>These were specific changes that I needed to make on the Remix side, but really it would be the same for any GraphQL request. As Andrew Welch breaks down in <a href="https://nystudio107.com/blog/headless-preview-in-craft-cms">his article</a>, the key is passing the token parameter back that Craft included in the URL.</p>
<p>In the loader function of my blog post route, I call a helper function to setup the GraphQL client, and I pass the request to it:</p>