Skip to content

fix(contentful-nextjs): draftMode() and page params are async since Next.js 15 - #94

Open
milescontentful wants to merge 2 commits into
contentful:mainfrom
milescontentful:fix/skill-quality-pass
Open

milescontentful wants to merge 2 commits into
contentful:mainfrom
milescontentful:fix/skill-quality-pass

Conversation

@milescontentful

Copy link
Copy Markdown

Summary

The Draft Mode reference example (skills/contentful-nextjs/references/preview-and-draft-mode.md) still showed the pre-Next.js-15 synchronous form:

export default async function Page({ params }: { params: { slug: string } }) {
  const { isEnabled } = draftMode();
  const entry = await getEntryById(params.slug, isEnabled);

draftMode() has been async since v15.0.0-RC, and page params became a Promise in the same release. Copying this example as-is on a current Next.js project produces a type error (or triggers the deprecated synchronous-access warning, which Next.js says will stop working in a future version).

Fixed to await both, matching the current official docs example.

Test plan

  • Confirmed the fix against the live Next.js docs (draftMode API reference, version 16.2.12, "Good to know" section: "draftMode is an asynchronous function that returns a promise... In version 14 and earlier, draftMode was a synchronous function... this behavior will be deprecated in the future").
  • python3 local-skills/skills/skill-authoring/scripts/quick_validate.py skills --all — 7/7 skills pass, including contentful-nextjs.
  • Scoped to this one file — no other changes.

🤖 Generated with Claude Code

…ext.js 15

The Draft Mode reference example still used the pre-15 synchronous form
(`draftMode()` called without await, params destructured without awaiting
the Promise). Both became async in Next.js 15.0.0-RC — draftMode() has
been async since https://nextjs.org/docs/app/api-reference/functions/draft-mode#version-history,
and dynamic page params followed the same change. Anyone copying this
example on current Next.js gets a type error (or a runtime warning under
the deprecated sync-access shim).

@Lp-Francois François (Lp-Francois) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants