Right now it seems everything works. I hit preview, it opens my localhost, it goes to the page, it shows the loader, then it seems to refresh and error.
The preview documentation in the Next.js docs is not currently compatible with version v6 of @prismic/client, we're are currently working on releasing a much easier to use Next.js preview implementation in the following few weeks. Once this is released we'll update you here.
For the moment if you want to use previews with Next.js is best to stay on client v5.
Yes, that's the way you can get work Previews in your Next.js Project. Thanks.
@beamer, I have checked your project code. You are currently passing req in the Client function, but it needs to be set up differently.
You need to enable the client to automatically query content from a preview session if one is active in server environments. This is disabled by default on the server. This change was made to make it very clear how the req object will be used.
You need to set req in client.enableAutoPreviewsFromReq(req). It will enable automatic previews from a server Request object.
Let me know if that doesn't fix it and I'll look again.
I'm not familiar with prismic-client v6 that much. But if you data fetching part is working correctly? What I mean, is your serviceCategoriesData returns data with preview data?
Because at this point, you will pass data to components which will be rendered. So we have to get preview before return.
@Priyanka this is SO helpful. I don't know where I got the code previously - i thought i was doing best practices. I don't think i realized the new docs were still coming out.
ok so i'm close! i believe this is working. but do you mind sharing me your SliceZone component from components/post?
In this project I was using SliceZone from @prismicio/react
but in another project I've hacked together a working next-slicezone - but there was a slice capitalization issue. I made a workaround that maps the names to camel case but - requires some manual attention.
Hello I'm still experiencing some issues with the new prismic client (v6) and previews.
I've noticed that the getByID method does not work if you use a doc id for a document that is in another locale than the default one. For example, my repo default locale is in fr-fr so this works
So the problem is that the resolvePreviewURL is not returning any document when trying to preview a "en-gb" document because it does not find it, here is the part causing this :
+1 - I am having the exact same issue when previewing non master locales.
Master locale previews work fine (published and unpublished content), but I cannot preview data from any non master locale. I get the same error.
I have looked into your files. I could not find next.config.js into that.
In nextjs, there are different properties available for language redirection, such as locale,locales, and defaultLocale . These properties need to be used in next.config.js.
It's a known issue with @prismicio/client version 6.0.0. If you have the older version, can you update @prismicio/client to v6.1.0? It includes a fix for previewing documents from locales other than the master locale.