'CreateClientConfig' is deprecate, and previewData' does not exist in type 'EnableAutoPreviewsConfig

I'm getting 'CreateClientConfig' is deprecated.
and previewData' does not exist in type 'EnableAutoPreviewsConfig

import { Env } from '@/lib/env'
import * as prismic from '@prismicio/client'
import * as prismicNext from '@prismicio/next'
import { repositoryName } from '../repo'
import { routes } from '../routes'

const createClient = (config: prismicNext.CreateClientConfig = {}) => {
  const client = prismic.createClient(repositoryName, {
    routes,
    fetchOptions:
      Env.NODE_ENV === 'production'
        ? { next: { tags: ['prismic'] }, cache: 'force-cache' }
        : { next: { revalidate: 5 } },
    ...config,
  })

  prismicNext.enableAutoPreviews({
    client,
    previewData: config.previewData,
    req: config.req,
  })

  return client
}

const client = createClient()

export { client }

i have changed it to prismic.ClientConfig and the error goes away, how ever the preview data error persist

Object literal may only specify known properties, and 'previewData' does not exist in type 'EnableAutoPreviewsConfig'.ts(2353)

(property) previewData: any
Property 'req' does not exist on type 'ClientConfig'.ts(2339)

any

Hi @eloquentpeasant, thank you for the bug report.

We added a step to the @prismicio/next v2 upgrade guide that address this:
Replace CreateClientConfig in prismicio.ts

Could you try it and let us know if it fixes the error?

1 Like

thank you so much for your answer, that indeed did fix the issue appreciate your help

2 Likes