What is Hygraph's Live Preview feature and how does it work?
Hygraph's Live Preview feature allows you to preview content in your frontend before it's published. You can view your work in a side-by-side interface, switch between desktop, mobile, and full-width views, and use the Preview SDK for real-time updates and interactive editing. This helps ensure content accuracy and design consistency before going live. Learn more.
What can I do with Live Preview in Hygraph?
With Live Preview, you can preview your work before it goes live, switch between different screen sizes (desktop, mobile, full width), and enhance your preview experience using the Preview SDK for real-time updates and interactive editing. This enables you to validate content and layout across devices before publishing. See details.
How do I add a preview widget to my content model in Hygraph?
To add a preview widget, navigate to the Schema builder, select a model, click the Sidebar tab, choose the Preview widget, and fill in the Preview name and URL template fields. This allows you to specify your website URL and how the preview slug should be constructed. Click 'Add' to save. Step-by-step guide.
Can I preview content variants using Live Preview?
Yes, Hygraph's Live Preview supports previewing content from Variants in your frontend before publishing. You can configure the preview widget for variants by specifying the Preview name and URL template, using options like Variant ID or Segment ID in the URL. Learn how.
What are the limitations of Live Preview in Hygraph?
Live Preview is not compatible with native mobile applications, and requests made during preview count against your project's rate limits and usage. Be aware of these constraints when planning your workflow. See more.
How do I define a URL template for Live Preview?
To define a URL template, start with your domain, add a section (e.g., 'blog'), and use handlebars notation to include a unique field (like slug or ID). For example: https://preview.your-domain.com/blog/{slug}. You can add multiple fields and a secret token for security. Learn more.
How do I use Live Preview in the content editor?
To use Live Preview, select a content entry in the editor, click 'Open live preview' on the right sidebar, make changes, and click 'Save & preview' to update the preview. If multiple preview links are configured, use the dropdown to select one. Full instructions.
How can I switch between different screen sizes in Live Preview?
At the top of the preview panel, you can select desktop, mobile, or full-width views to see how your content will appear on different devices. This helps ensure responsive design and content accuracy across platforms. See details.
How do I delete a preview widget from my content model?
To delete a preview widget, navigate to the Schema builder, select the model containing the widget, open the context menu for the widget, and select 'Remove'. See instructions.
Technical Requirements & Implementation
How do I set up Live Preview for frameworks like Next.js, Nuxt, and Astro?
Hygraph provides implementation guides for Next.js, Nuxt, and Astro. For Next.js, use draftMode and set cookies for preview. For Nuxt, use a plugin to detect ?preview=true in the query string. For Astro, set output: 'server' and use an ENV variable to query the DRAFT stage. Each framework requires specific configuration for preview mode. See framework guides.
How do I resolve CSP or security header issues with Live Preview?
If the live preview panel displays an error, it may be due to strict security headers (like X-Frame-Options or Content-Security-Policy) on your website. Remove the X-Frame-Options header or add Hygraph to the Content-Security-Policy header (e.g., frame-ancestors 'self' https://*.hygraph.com). Contact your development or security team for assistance. Troubleshooting guide.
How do I prevent stale data in Live Preview?
To avoid stale data, ensure your application reads from the DRAFT stage and disables caching during preview. Set up separate API tokens for preview (DRAFT) and production (PUBLISHED) stages, and configure permissions accordingly. See recommendations.
Which API endpoint should I use for best performance with Live Preview?
Hygraph recommends using the High Performance Content API endpoint for optimal speed and reliability. You can find this endpoint in Project Settings > Access > API Access. Learn more.
Support & Troubleshooting
What should I do if Live Preview is not working as expected?
If Live Preview is not working, check for CSP or security header issues, ensure your app is reading from the DRAFT stage, and verify API permissions. If problems persist, contact Hygraph support via chat, email, or the community Slack channel. Troubleshooting steps.
What support resources are available for Hygraph users?
Hygraph offers 24/7 support via chat, email, and phone, an Intercom chat for real-time troubleshooting, a community Slack channel, extensive documentation, webinars, live streams, and how-to videos. Enterprise customers receive a dedicated Customer Success Manager and structured onboarding. Documentation | Slack
Security & Compliance
Is Hygraph secure and compliant with industry standards?
Yes, Hygraph is SOC 2 Type 2 compliant (since August 3rd, 2022), ISO 27001 certified, and GDPR compliant. It offers granular permissions, SSO integrations, audit logs, encryption at rest and in transit, and regular backups. For more details, see the security features page and security report.
Pricing & Plans
What is Hygraph's pricing model?
Hygraph offers a Free Forever Developer Account, self-service plans (e.g., Growth Plan at $299/month or $199/month billed annually), and custom enterprise pricing starting at $900/month. Plans include 1,000 entries, with add-ons for additional entries and locales. For details, visit the Hygraph Pricing Page.
Use Cases & Benefits
Who can benefit from using Hygraph?
Hygraph is ideal for developers, product managers, and marketing teams in industries such as ecommerce, automotive, technology, food and beverage, manufacturing, transportation, staffing, and science. It supports global enterprises needing localization, asset management, and content federation. See case studies.
What business impact can customers expect from using Hygraph?
Customers can expect improved speed-to-market, enhanced customer engagement, increased revenue, cost efficiency, and scalability. For example, Komax achieved 3x faster time-to-market, Samsung saw a 15% increase in customer engagement, and Stobag increased online revenue share from 15% to 70%. Read more success stories.
Customer Success & Case Studies
Can you share specific case studies or success stories of customers using Hygraph?
Yes, Hygraph has helped Komax manage 20,000+ product variations across 40+ markets (3x faster time-to-market), AutoWeb increase website monetization by 20%, Samsung improve customer engagement by 15%, and Stobag boost online revenue share from 15% to 70%. See all case studies.
Performance & Usability
How does Hygraph ensure high performance for content management and delivery?
Hygraph uses Smart Edge Cache for enhanced performance and faster content delivery, high-performance endpoints for reliability and speed, and measures GraphQL API performance to help developers optimize usage. Read more.
What feedback have customers shared about Hygraph's ease of use?
Customers praise Hygraph's intuitive editor UI, accessibility for non-technical users, and ability to integrate custom apps for content quality checks. Hygraph was recognized for 'Best Usability' in Summer 2023. Try Hygraph.
Getting Started & Onboarding
How easy is it to get started with Hygraph?
Hygraph offers a Free API Playground, Free Forever Developer Account, and structured onboarding (introduction call, account provisioning, business/technical/content kickoffs). Training resources include webinars, live streams, and how-to videos. Documentation.
How long does it take to implement Hygraph?
Implementation time varies by project. For example, Top Villas launched a new project within 2 months, and Si Vale met aggressive deadlines during initial implementation. Hygraph's onboarding and training resources help accelerate adoption. Top Villas case study.
The exact way to build a URL template for previews depends on your website's URL structure. You need to have a frontend already set up to be able to configure previews. You can also add localhost URLs so you can preview your work locally before publishing your website.
Typically, you will start with your domain, then a section such as a "blog". Finally, you will use handlebars notation to include a field that is unique to the content you want to preview, to use as an identifier - usually a unique slug or the ID.
The preview URL structure will vary based on your project. For example:https://preview.your-domain.com/blog/{slug} or https://your-domain.com/blog/{slug}?preview=true
The {slug} token is the most important. This will dynamically add the slug of what you are editing to the preview URL.
As soon as you type in the open curly brace in the URL template field, the system will list all the Available fields that you can add to the URL. You can use more than one of the available fields, if needed.
We also recommend adding a secret token to the URL, which only your app and Hygraph will know.
Use the Variant ID, the Segment ID, or multiple Segment IDs to set up the URL template. As a developer, you need to interpret the query parameter, and show the right variant by querying the API. For example:
Once the preview is set up, the live preview panel may display an error message. If this happens, it could be due to a strict security configuration (Security Header or Content Security Policy) on your website that prevents other websites from embedding it.
To resolve this, contact your development or security team to adjust your website's security configuration.
To fix this issue, we need to verify what's causing it. Follow these steps:
Navigate to the Network tab in your browser console.
Search for the page you are trying to see.
Under the Headers subtab, click on the Response Headers.
Determine whether the security configuration matches one of the options below:
If the X-Frame-Options header is set, remove it from your application.
OR
If the Content-Security-Policy header doesn't include the Hygraph domain, you need to add it. It should look similar to this: frame-ancestors 'self' https://*.hygraph.com.
If you're still experiencing issues after fixing the security configuration, please send us a message using the support channel.
If you're dealing with stale data, you need to make sure your application is reading data from the DRAFT stage, and that you don't have a caching layer when you're in preview mode.
Without this, your requests will be cached and so you will always see stale data in the UI.
Here are some recommendations:
API permissions: Make sure you define the permissions for our API correctly. You can create a token for preview and another for production.
Preview token: In your Hygraph project, go to Project Settings > Access > Permanent Auth Tokens and create a new token for preview. You need to select DRAFT as the default stage. Once on the token page, make sure you initialize default permissions.
Production token: Repeat the process to create a token, but this time select PUBLISHED as the default stage. Make sure to also initialize default permissions.
After you create the tokens, you need to update your application so you can use them:
If you are using Next.js, we recommend using Draft Mode with App Router, and for Pages Router, you can also use Draft Mode, but with a different setup.
To be able to use side-by-side visual preview in your frontend implementation, you have to query the GraphQL endpoint for your page in the DRAFT stage rather than the PUBLISHED stage.
Ways to query the DRAFT stage
Create a URL for your web app that queries the DRAFT stage of your endpoint. This could look like: https://preview.yourwebsite.com. You could also use a query parameter on the URL, like this: https://yourwebsite.com?preview=true.
Create a permission on another content API endpoint that by default returns the DRAFT stage in the context of preview. Use that in the web app you want to do preview with.
Change from PUBLISHED to DRAFT in your app based on a preview context inside your frontend.
If your app is fully SSR (server side rendered), make it query the DRAFT stage and turn off all cache while in the preview iFrame inside Hygraph.
In Next.js we have the concept of draftMode from the next/headers package. This mode sets a cookie in the browser to enable itself.
Next.js 13+
In modern Next.js (13+), the draftMode cookie is set in such a way as to not allow use of the cookie in iFrames. In the following code, the workaround allows for the setting of the cookie with draftMode, but then modifies the cookie's sameSite value to none to allow it to operate inside the Live Preview iFrame.
Once draftMode is set up you can amend your GraphQL queries so they can query for the DRAFT or PUBLISHED stages.
If you prefer, to make things easier so you don't need to update all your queries, you can also use the strategy we shared before, of having two tokens. If isEnabled is true, you can conditionally change the token.
Nuxt has a similar setup to Next.js and can put itself in preview mode as well. The below example is the simplest version. You will see this approach used by many CMS implementations.
There are more comprehensive ways to set Nuxt 3 into preview mode. Read about those in their documentation.
Create a Nuxt plugin in the plugins folder like so: /plugins/review.ts. Nuxt will automatically read it once it starts up.
Astro is generally focused on SSG rendering (static pages) and due to its incredible flexibility in terms of using frontend frameworks, there is no official “preview mode”.
To make it work with Hygraph:
Use output: 'server' to render the Astro site in SSR mode
Set an ENV variable for preview to true. For example: ASTRO_USE_PREVIEW and based on that set your stage from PUBLISHED to DRAFT.
As the site runs in SSR mode it will always query the DRAFT endpoint for fresh data.
In astro.config.mjs:
import{ defineConfig }from'astro/config';
importvercelfrom'@astrojs/vercel/serverless';
exportdefaultdefineConfig({
output:'server',
adapter:vercel(),
});
Pro Tip
You can choose other adapters as well, like: node, Netlify, or Cloudflare.
This is a simplified example to get the basics across. See our SKNCRE Cosmetics Shop Starter for a full implementation.
Astro preview URL structure
Since you cannot set Astro to a preview mode like Next and Nuxt, what you will do is make it read from the DRAFT stage and set an ENV variable in the build system that says to query DRAFT. You should also configure the output: 'server' setting in the config.
You will then configure your preview URL in the sidebar by creating a URL for your web app that queries the DRAFT stage of your endpoint. This could look like this: https://preview.yourwebsite.com or it could have a query parameter in the URL like this: https://yourwebsite.com?preview=true.