Next.js App Router example showing Hygraph Preview SDK integration.
-
Install dependencies:
npm install
-
Create
.env.local:NEXT_PUBLIC_HYGRAPH_ENDPOINT=https://your-region.cdn.hygraph.com/content/your-project-id/master NEXT_PUBLIC_HYGRAPH_STUDIO_URL=https://app.hygraph.com HYGRAPH_TOKEN=your-permanent-auth-token # Optional: Required if your project uses authentication -
Run the server:
npm run dev
The wrapper component (src/components/PreviewWrapper.tsx) loads the Preview SDK and refreshes content when saved using router.refresh().
Standalone: Open in your browser, hover over content to see edit buttons.
Studio Integration: Use this URL in your Hygraph preview settings.
Uses the recipe schema from ../schema.json. See main examples README for setup.