Unverified Commit b350da47 authored by Marjan Ahmed's avatar Marjan Ahmed Committed by GitHub

docs: fix generateImageMetadata example to use normal params object (#85658)

### What?

Fixes an inconsistency in the v16 upgrade documentation for
`generateImageMetadata`.

### Why?

In the “Upgrading to Version 16” guide, the example incorrectly awaited
the `params` object inside `generateImageMetadata`, implying that it was
a Promise.
However, according to the API reference, `params` is a normal object.
This PR updates the example to reflect the correct synchronous usage.

### How?

Replaced:
```ts
export async function generateImageMetadata({ params }) {
  const { slug } = await params
  return [{ id: '1' }, { id: '2' }]
}

With
```ts
export async function generateImageMetadata({ params }) {
  // params is a normal object
  return [{ id: '1' }, { id: '2' }]
}

---------
Co-authored-by: 's avatarJoseph <joseph.chamochumbi@vercel.com>
parent c2f1062b
......@@ -322,12 +322,11 @@ export default function Image({ params, id }) {
}
```
Starting with **Next.js 16**, to align with the [Async Request APIs](#async-request-apis-breaking-change) change, these are also asynchronous.
Starting with **Next.js 16**, to align with the [Async Request APIs](#async-request-apis-breaking-change) change, the image generating function now receives `params` and `id` as promises. The `generateImageMetadata` function continues to receive synchronous `params`.
```js filename="app/shop/[slug]/opengraph-image.js"
// Next.js 16 - asynchronous params access
export async function generateImageMetadata({ params }) {
const { slug } = await params
const { slug } = params
return [{ id: '1' }, { id: '2' }]
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment