Next.js + Prismic Previews - Cannot exit preview

Hey there,

I can successfully view previews, however clicking the "X" button on the preview toolbar reloads the site yet does not trigger the api/exit-preview endpoint or clear the Next.js preview cookie.

I see some posts dating back to Oct of last year but I still don't have a clear idea about how this works.

  1. Does clicking on the toolbar's "X" button trigger the exit-preview api endpoint under the hood?
  2. I read in another post somewhere that the X button doesn't actually tell Next.js to end its preview state. So the Prismic does seem to suggest that hitting this endpoint is manually needed on our end to exit.

Exploring the Network tab in the browser tools, I don't see api/exit-preview being hit.

Any suggestions?


Hi Kevin,

We've made some changes to our recommendations on how to set up previews with Next.js as it's a tricky technology for working with Previews. You can follow the documentation below which will show you how to configure your project so that the api/exit-preview route is triggered when you click the "X" button on the preview toolbar.

Let me know if you have any questions.