# Previewing unpublished changes doesn't work

**URL:** <https://community.prismic.io/t/previewing-unpublished-changes-doesnt-work/9298>\
**Category:** Developing with Prismic\
**Tags:** gatsby\
**Created:** [March 8, 2022, 9:56am UTC](https://community.prismic.io/t/previewing-unpublished-changes-doesnt-work/9298 "2022-03-08T09:56:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![josefine](https://avatars.discourse-cdn.com/v4/letter/j/958977/32.png) [@josefine](https://community.prismic.io/u/josefine)\
**Post date:** [March 8, 2022, 9:56am UTC](https://community.prismic.io/t/previewing-unpublished-changes-doesnt-work/9298/1 "2022-03-08T09:56:42Z")

</div>

Hi!

I'm trying to configure Prismic previews in a Gatsby project with the `gatsby-plugin-prismic-previews`.

Previewing published content works well. Also previewing completely new content that is unpublished works well (it will use the 404 page and the HOC `withPrismicUnpublishedPreview` to resolve this).

The one issue we have is when updating an existing document that is already live and published. Then you will have some draft changes that are unpublished.  
When trying to preview that document it will launch the preview and display the original document that is the one that is already live.  
How is the plugin suppose to detect that we have some draft changes and display that instead?

It is key to be able to preview changes that you are about to publish. So I assume we are missing something in the configuration.

We use a very simple setup in the `gatsby-browser.js`.

```auto
<PrismicPreviewProvider
    repositoryConfigs={[
      {
        repositoryName: "our_repo_name",
        linkResolver,
        componentResolver: componentResolverFromMap({
          post: PostTemplate,
        }),
      },
    ]}
  >
    {element}
  </PrismicPreviewProvider>

```

And minimum options in `gatsby-config.js`.

```auto
{
      resolve: "gatsby-plugin-prismic-previews",
      options: {
        repositoryName: "our_repo_name",
        accessToken: "the_access_token",
      },
    },

```

I mean the integration seems to work well except for the use case I described.

---

<div class="post-metadata">

**Author:** ![Priyanka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/priyanka/32/3223_2.png) [@Priyanka](https://community.prismic.io/u/Priyanka)\
**Post date:** [March 8, 2022, 1:04pm UTC](https://community.prismic.io/t/previewing-unpublished-changes-doesnt-work/9298/3 "2022-03-08T13:04:51Z")

</div>

Hello @josefine

Welcome to the Prismic community and thanks for reaching out to us.

Have you also added a \_previewable field to the query and declared the [withPrismicPreview()](https://prismic.io/docs/technologies/gatsby-plugin-prismic-previews-technical-reference#withprismicpreview) function. This setup will automatically detect an active preview session and update the content with the preview data.  
Find more details [here](https://prismic.io/docs/technologies/previews-gatsby#3.-update-content-pages-and-templates).

Thanks,  
Priyanka

---

<div class="post-metadata">

**Author:** ![josefine](https://avatars.discourse-cdn.com/v4/letter/j/958977/32.png) [@josefine](https://community.prismic.io/u/josefine)\
**Post date:** [March 9, 2022, 7:52am UTC](https://community.prismic.io/t/previewing-unpublished-changes-doesnt-work/9298/4 "2022-03-09T07:52:36Z")

</div>

Thank you very much @Priyanka , that is the solution. Not sure how we missed that in the docs 🙂

---

<div class="post-metadata">

**Author:** ![Priyanka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/priyanka/32/3223_2.png) [@Priyanka](https://community.prismic.io/u/Priyanka)\
**Post date:** [March 9, 2022, 10:06am UTC](https://community.prismic.io/t/previewing-unpublished-changes-doesnt-work/9298/5 "2022-03-09T10:06:13Z")

</div>

You are welcome, @josefine. Feel free to reach out to us if you have any questions.
