Previews in Next.js using GraphQL

Hi, are there any examples that show how I can enable previews using the PrismicLink for GraphQL?
I see the docs for integrating GraphQL (in general) but I don’t see any examples of enabling preview with Next.js using this setup.

Thanks.

I came across https://github.com/zeit/next.js/tree/canary/examples/cms-prismic. It is a complete example with previews integration that uses the REST api. You could switch out the data fetching part to PrismicLink and useQuery and it should work.

Thanks for the reply.

Yeah, I’ve looked at that example but my setup is quite different :sweat_smile:.

I’m using babel-plugin-graphql-import so all my queries are in separate files to keep things organized.

I’ve noticed that they are changing the ref here, but how would that work using useQuery?

Hi @iwatakeshi, sorry for the delayed response. We somehow missed this thread originally. Are you still having issues with the Previews?

If so, I have a React project that that you can explore that has previews working with the GraphQL API:

Let me know if this helps you figure out the issue or if you still aren’t able to get things working.

1 Like