Nextjs 15 and Draftmode

Describe your question/issue in detail

Impacted feature

This impact the preview function and missing Draftmode()

What steps have you taken to resolve this issue already?

**
 * Creates a Prismic client for the project's repository. The client is used to
 * query content from the Prismic API.
 *
 * @param config - Configuration for the Prismic client.
 */
export const createClient = (config: prismicNext.CreateClientConfig = {}) => {
  const client = prismic.createClient(sm.apiEndpoint || repositoryName, {
    routes,
    fetchOptions:
      process.env.NODE_ENV === "production"
        ? { next: { tags: ["prismic"] }, cache: "force-cache" }
        : { next: { revalidate: 5 } },
    ...config,
  });

  prismicNext.enableAutoPreviews({ client });

  return client;
};

Errors

Error: In route / a draftMode() property was accessed directly with draftMode().isEnabled. draftMode() should be awaited before using its value.

Hosting provider

localhost

Package.json file

`"@prismicio/client": "^7.11.0",
"@prismicio/next": "^1.7.0",
"@prismicio/react": "^2.9.0",
"next": "15.0.0",

Steps to reproduce

Update to Nextjs 15 and npm run dev

same issue here, only downgrade back to 14 / react 18 fixes this atm

Hi there, thanks for joining our community!

We share your excitement about Next 15 and are working on supporting it with @prismicio/next. The change on draftMode() from a sync to an async function impacts some of our helpers, we'll release a compatible version soon.

Hey, to add to this, the app/slice-simulator/page.tsx is also affected by Next 15. The searchParams type SliceSimulatorParams also needs to be a Promise<>

I'm sure you'll are working on a fix, just wanted to add this to the thread.

1 Like

Hi do we have update on when will this compatible version release?

This seems related to the issue i have with the new Next 15

Hi @n.belandres, we released last month @prismicio/next v1.7.1 which supports Next 15 :slight_smile:

Let us know if you have any trouble using Next 15 and Prismic, happy to help!