Add clickable edit buttons to your Hygraph content preview. Hover a tagged element to show Edit, open the matching field in Studio, and refresh the preview when content is saved.
Works with React, Next.js, Remix, Vue, Nuxt, and vanilla JavaScript.
npm install @hygraph/preview-sdkFull setup, framework guides, and API reference live in the Hygraph docs:
- Click to Edit setup — install, attributes, Studio widget, troubleshooting
- Advanced API — React hooks, Preview methods, DOM events, helpers
- Framework guides:
import dynamic from 'next/dynamic';
import { useRouter } from 'next/navigation';
const HygraphPreview = dynamic(
() => import('@hygraph/preview-sdk/react').then((mod) => ({ default: mod.HygraphPreview })),
{ ssr: false }
);
export function PreviewWrapper({ children }) {
const router = useRouter();
return (
<HygraphPreview
endpoint={process.env.NEXT_PUBLIC_HYGRAPH_ENDPOINT}
studioUrl={process.env.NEXT_PUBLIC_HYGRAPH_STUDIO_URL}
onSave={() => router.refresh()}
>
{children}
</HygraphPreview>
);
}Mark content with data-hygraph-* attributes (or the helpers from @hygraph/preview-sdk/core). See the setup guide for the full walkthrough.
Runnable apps in this repository:
See examples/README.md for schema setup and how to run them.
MIT © Hygraph