# Prismic Preview Mode does not provide preview Refs (Nextjs)

**URL:** https://community.prismic.io/t/prismic-preview-mode-does-not-provide-preview-refs-nextjs/1558
**Category:** Developing with Prismic
**Tags:** nextjs
**Created:** [August 16, 2020, 11:47am UTC](https://community.prismic.io/t/prismic-preview-mode-does-not-provide-preview-refs-nextjs/1558 "2020-08-16T11:47:40Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![aman](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@aman](https://community.prismic.io/u/aman)
#### Post date: [August 16, 2020, 11:47am UTC](https://community.prismic.io/t/prismic-preview-mode-does-not-provide-preview-refs-nextjs/1558/1 "2020-08-16T11:47:40Z")

</div>

Hi everyone 👋

I have been having a little bit of struggle with the preview mode. To fetch the unpublished posts, we would need to preview ref, and this is how it is done on the Prismic's NextJS page:

```
const Preview = async (req, res) => {
const { token: ref, documentId } = req.query;
const redirectUrl = await Client(req)

```

So within `req.query`, there should be token, within which I would find the `ref` and the `documentID`. In my case, `token` does _not_ have any items inside it. It is a string. Something similar to this:

`https://example-repository.prismic.io/previews/XzjsUxJFIEKGAAAK:XzfX3BVHSOWAzIaf?websitePreviewId=GKHCDOBLDJW`

Is there a reason for that? Currently I am fetching the preview string from the prismic cookie that prismic's preview library script automatically adds. But I would love to do it without it and take it right from the query.

---

<div class="post-metadata">

### Author: ![Levi](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/levi/32/24_2.png) [@Levi](https://community.prismic.io/u/Levi)
#### Post date: [August 17, 2020, 1:31pm UTC](https://community.prismic.io/t/prismic-preview-mode-does-not-provide-preview-refs-nextjs/1558/2 "2020-08-17T13:31:29Z")

</div>

Hi @aman, thanks for reaching out about this.

This syntax in Javascript might be a little confusing.

`const { token: ref, documentId } = req.query;`

What it is doing is retrieving the token from the req.query and assigning it to the variable `ref`. It is also retrieving the documentId from the req.query. That code snippet is the same as the following:

```auto
const ref = req.query.token;
const documentId = req.query.documentId;

```

So what you are seeing is correct. The token should be the url string that you are seeing. That url string is the preview ref.

---

<div class="post-metadata">

### Author: ![Fares](https://avatars.discourse-cdn.com/v4/letter/f/71e660/32.png) [@Fares](https://community.prismic.io/u/Fares)
#### Post date: [September 23, 2020, 4:48pm UTC](https://community.prismic.io/t/prismic-preview-mode-does-not-provide-preview-refs-nextjs/1558/3 "2020-09-23T16:48:17Z")

</div>

This issue has been closed due to inactivity.

---

<div class="post-metadata">

### Author: ![system](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/system/32/1746_2.png) [@system](https://community.prismic.io/u/system)
#### Post date: [December 9, 2021, 5:28pm UTC](https://community.prismic.io/t/prismic-preview-mode-does-not-provide-preview-refs-nextjs/1558/4 "2021-12-09T17:28:32Z")

</div>


