Skip to content

Repository files navigation

Hygraph Preview SDK

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.

npm version License: MIT

Works with React, Next.js, Remix, Vue, Nuxt, and vanilla JavaScript.

Installation

npm install @hygraph/preview-sdk

Documentation

Full setup, framework guides, and API reference live in the Hygraph docs:

Quick peek

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.

Examples

Runnable apps in this repository:

See examples/README.md for schema setup and how to run them.

Support

License

MIT © Hygraph

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages