next.js
8669b07f - fix(cms-contentful): await draftMode() and use Promise<> params type (#95631)

Commit
125 days ago
fix(cms-contentful): await draftMode() and use Promise<> params type (#95631) ### What? Fix the `cms-contentful` example to use the async APIs introduced in Next.js 15: - Await `draftMode()` in `app/page.tsx`, `app/posts/[slug]/page.tsx`, and `app/api/disable-draft/route.ts` - Update `params` type to `Promise<{ slug: string }>` and await it in `app/posts/[slug]/page.tsx` ### Why? In Next.js 15, `draftMode()` from `next/headers` became async and must be awaited. Page `params` are also now typed as a `Promise`. The example was using the old synchronous patterns, causing the build to fail and the app to not work when running against the latest version of Next.js -- this example project uses latest version of next.js in the package.json. ### How? Awaited `draftMode()` at each call site and updated the `params` type signature to `Promise<{ slug: string }>` with a corresponding `await`. Closes NEXT- Fixes #
Author
Parents
Loading