Error in boilerplate code for Next.js previews docs

Reviewing the documentation for "Preview Content Changes" in Next.js. I noticed an error in the boilerplate code for the "useUpdatePreviewRef.js" hook.

Current code that passes the token "previewCookieRef" as a string:

else if (rawPreviewCookie && previewCookieRef) {
    return router.push(`/api/preview?token=previewCookieRef&documentId=${documentId}`)
}

The working modified code that passes token "previewCookieRef" as a template literal:

else if (rawPreviewCookie && previewCookieRef) {
    return router.push(`/api/preview?token=${previewCookieRef}&documentId=${documentId}`);
}

This change solved one of the issues I was running into when testing previews with Next.js.

Hit me up with any further questions.

@nathan Good catch! Thanks so much for pointing this out. I'll make sure this gets updated right away.

Let us know if you find anything else that needs fixed or clarification in the future :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.