prismicio/prismic-next

PrismicToolbar not loading

Closed this issue · 5 comments

Versions

  • package_name: "@prismicio/next": "^0.0.1"
  • node: v16.10.0

Reproduction

Seems that I'm just supposed to wrap it in _app.tsx but I can't seem to get it to show

<PrismicPreview repositoryName="wondervalley">
  <Component {...pageProps} />
</PrismicPreview>

Hey @beamercola, the Prismic toolbar should appear under at least one of the following conditions:

  1. You are logged in to Prismic for the toolbar's configured repository (wondervalley in this case)
  2. You are in a preview session

Otherwise, the toolbar script should be injected into the app's DOM, but the toolbar will not appear. Can you confirm that at least the <script> element has been appended to the <body> element?

Yea the script is there, I'm logged in. I clicked preview from the editor, but no show.

Side note, I know I already mentioned this but Brave constantly logs me out. Safari is fine so I'm using that. But just in case that's related shrug

Thanks Angelo

Hey @beamercola,

Can I see your prismic preview function? Should just be what you have in /pages/api/preview.js

import { linkResolver, createClient } from "prismic.client"
import * as prismicNext from "@prismicio/next"
import { NextApiRequest, NextApiResponse } from "next"

export default async function (req: NextApiRequest, res: NextApiResponse) {
  const client = createClient({ req })
  prismicNext.setPreviewData({ req, res })
  await prismicNext.redirectToPreviewURL({ req, res, client, linkResolver })
}

Closing this because this shouldn't be an issue with the latest version. If this is still an issue even then feel free to comment here and I'll open it back up!