Preview
Learn how to set up Prismic Previews in your repository.
This document tells developers how to add previews to a website. Are you a content editor looking for a guide on how to use previews? See Preview Drafts.
Prismic Previews allow you to view draft documents live on your website without publishing them publicly. You can set up many preview environments to preview your content in different contexts, such as production and development.
When a user launches a preview in the Writing Room, a temporary and secure ref (a token that references a specific content version) is generated for the preview session. Prismic sets a cookie with a token to access the preview. That cookie is included in the user's request when they request a draft document in the web app, allowing them to view the page.
In your repository, go to Settings > Previews > Manage your Previews and select Create a preview. Then fill in the new preview configuration:
- Site Name: The display name to identify the website in the preview.
- Domain for Your Application: The URL of your site, such as
https://example.com/
orhttp://localhost:3000/
- Preview route: A route in your app that provides a link resolver. Some of Prismic's app development kits create this route for you at
/preview
.
![Screenshot of a repository's preview configuration](https://images.prismic.io/prismicio-docs-v3/d94de382-04e8-49b4-a238-655bf948d1eb_preview.png?auto=compress%2Cformat&rect=0%2C0%2C1107%2C472&w=1920&fit=max)
Once you have configured Previews in your repository, you need to implement the preview functionality in your project code.
The syntax and configuration process of the Preview functionality varies for each technology. We recommend reading the Preview documentation for your chosen technology to learn how to set it up in your project:
The Prismic Toolbar works together with Previews, giving you a list of the documents in the preview and a link to open them in the Writing Room.
![Screenshot of the toolbar and edit button](https://images.prismic.io/prismicio-docs-v3/ce433eca-9813-4f92-b88d-387fc0e96f00_editbtn.png?auto=compress%2Cformat&rect=0%2C0%2C1679%2C198&w=1920&fit=max)
The toolbar works by adding a Prismic script in your code that automatically detects when a user is browsing the website in a preview session. You can find the script in your repository Settings > Previews > Include the Prismic Toolbar.
The script looks like this, with your repository name instead of your-repo-name
:
<script async defer src="https://static.cdn.prismic.io/prismic.js?new=true&repo=your-repo-name"></script>
Prismic's development kits and plugins for some frameworks (such as Nuxt.js, Next.js, and Gatsby) add this script automatically, so you don't need to worry about it. To learn more, see the documentation for your chosen technology.
The Prismic Toolbar provides shareable links, which allow you to share live previews of drafts with anyone. These links are useful when sharing a page preview with teammates or giving early access for stakeholder validation.
![Screenshot of the Get shareable link option of the toolbar.](https://images.prismic.io/prismicio-docs-v3/5f68fe15-d773-4cc8-a358-1910f0ec3c78_sharelin.png?auto=compress%2Cformat&rect=0%2C0%2C1516%2C753&w=1920&fit=max)
To get your shareable link, open a preview session and select Get a shareable link, then click on Copy the link, and you're all set. You can now share this URL.
Can't find what you're looking for?
Need technical Support? Spot an error in the documentation? Get in touch with us on our Community Forum.