Share static props with layout #29329
Unanswered
MauricioRobayo
asked this question in
Help
Replies: 2 comments
-
That's what I'd do too, but i don't know if it's the best approach. It could be nice to add a section in the doc. Btw they do that for nextjs commerce : https://github.com/vercel/commerce/blob/main/pages/_app.tsx |
Beta Was this translation helpful? Give feedback.
0 replies
-
That's also what I'm doing. I think for now it's a good approach actually. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm fetching some data with
getStaticProps
that I want to make available to a layout, I'm not sure how to do this so I'm passingpageProps
on_app
to thegetLayout
function.Following the With TypeScript example from the docs, It would look something like this:
And on the pages sharing the layout I'm using something like this:
This works so far, but I'm wondering if this is a good approach. I could not find a way of doing this in the documentation... any drawbacks? any issues about this approach that I should consider? Is there a better approach?
Beta Was this translation helpful? Give feedback.
All reactions