Add searchParams
to opengraph-image.tsx to allow for better OG image generation
#56314
Replies: 20 comments
-
Quarterly bump :) |
Beta Was this translation helpful? Give feedback.
-
One solution is to create a route (let's say It would still be great UX to be able to do this directly in opengraph-image.tsx |
Beta Was this translation helpful? Give feedback.
-
Bump- would be so useful |
Beta Was this translation helpful? Give feedback.
-
bump |
Beta Was this translation helpful? Give feedback.
-
Bump |
Beta Was this translation helpful? Give feedback.
-
Bump |
Beta Was this translation helpful? Give feedback.
-
bump |
Beta Was this translation helpful? Give feedback.
-
Time wasted on debugging this issue and looking for solution online: Feel free to increment it further :) this kind of issue is the reason for nextjs fatigue. production-ready my ass |
Beta Was this translation helpful? Give feedback.
-
Adding the workaround in the docs is a good start. The workaround being having a dedicated route for handling image requests. |
Beta Was this translation helpful? Give feedback.
-
Bump! |
Beta Was this translation helpful? Give feedback.
-
bump |
Beta Was this translation helpful? Give feedback.
-
Dynamic og generation is a great idea. +1 |
Beta Was this translation helpful? Give feedback.
-
Not a nextjs expert but while trying to todo this, the following guide with example was the only thing which was working for me as expected with the most recent nextjs 15. |
Beta Was this translation helpful? Give feedback.
-
Bump |
Beta Was this translation helpful? Give feedback.
-
Bump |
Beta Was this translation helpful? Give feedback.
-
Bump |
Beta Was this translation helpful? Give feedback.
-
bump |
Beta Was this translation helpful? Give feedback.
-
bump |
Beta Was this translation helpful? Give feedback.
-
bump |
Beta Was this translation helpful? Give feedback.
-
Kind of insane that 2 years later this still isn't possible. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
As the title says, I would love to be able to access
searchParams
inside opengraph-image.tsx files.This would allow you to generate a OpenGraph images based on
searchParams
(and therefore reflect URL state in the image).In a page.tsx, this works perfectly well:
Doing the same in opengraph-image.tsx leads to
searchParams
being undefined.As written in the documentation (https://nextjs.org/docs/app/api-reference/file-conventions/metadata/opengraph-image#props), it only has access to the
params
, which is not enough in my opinion.Let's say my page relied on storing state in the URL for shareability.
I would need opengraph-image.tsx to be able to access
input
here:example.com/?input=hello
Thanks, and I hope this will be considered, or that I am outdated and it actually works somehow :)
Beta Was this translation helpful? Give feedback.
All reactions