[Feature] Pages guards? #58653
gustaveWPM
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Currently, I'm putting some "Guards" in the
generateMetadata
function.Something like:
Where
blogPostGuard
is something like:I think it could be a good feature to have
declareGuard
function?Something like:
So that
declareGuard
would be executed BEFOREgenerateMetadata
andgenerateStaticParams
.Non-Goals
No response
Background
The current alternative is to put the guard in the
generateMetadata
.But I think this is not the most expressive way to achieve this.
Even though the documentation says:
I think it could be proper to define guards separately and document them.
Proposal
Idk. Maybe as
generateMetadata
, but as a function with a void return type?And then add it to the Next.js magic which is handling
generateMetadata
andgenerateStaticParams
, in order to make it run at first?I could be, if you think it is a good first contribution, simple enough for me to implement correctly with the right hints.
Beta Was this translation helpful? Give feedback.
All reactions