Skip to content

Commit

Permalink
improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
amannn committed Jan 10, 2025
1 parent fb8f88a commit e815f71
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ See the [App Router without i18n routing example](/examples#app-router-without-i

### Open Graph images

If you're programmatically generating [Open Graph images](https://nextjs.org/docs/app/api-reference/file-conventions/metadata/opengraph-image), you can apply internationalization by calling functions from `next-intl` in the exported function:
If you're programmatically generating [Open Graph images](https://nextjs.org/docs/app/api-reference/file-conventions/metadata/opengraph-image), you can call functions from `next-intl` in the exported component:

```tsx filename="opengraph-image.tsx"
```tsx filename="app/[locale]/opengraph-image.tsx"
import {ImageResponse} from 'next/og';
import {getTranslations} from 'next-intl/server';

Expand All @@ -121,7 +121,13 @@ export default async function OpenGraphImage({params: {locale}}) {
}
```

Next.js will create a public route based on the segment where `opengraph-image.tsx` is placed. However, if you're using [i18n routing](/docs/routing) and you've customized the [`localePrefix`](/docs/routing#locale-prefix) setting, this route might not be accessible due to a redirect or rewrite of the middleware.
Next.js will create a public route based on the segment where `opengraph-image.tsx` is placed, e.g.:

```
http://localhost:3000/en/opengraph-image?f87b2d56cee109c7
```

However, if you're using [i18n routing](/docs/routing) and you've customized the [`localePrefix`](/docs/routing#locale-prefix) setting, this route might not be accessible since Next.js doesn't know about potential rewrites of the middleware.

If this applies to your app, you can adapt your [matcher](/docs/routing/middleware#matcher-config) to bypass requests to the `opengraph-image.tsx` file:

Expand Down

0 comments on commit e815f71

Please sign in to comment.