Send Props From Page to _app #13753
-
Hi , i am working in next js Project and i wanna passe data from page to _app . |
Beta Was this translation helpful? Give feedback.
Answered by
jamesmosier
Jun 4, 2020
Replies: 1 comment 1 reply
-
It is not recommended, but you could pass them like...
function Index(){}
Index.isHome = true
export default function Index
function MyApp({Component,pageProps}){
console.log(Component.isHome)
return <Component {...pageProps}/>
} A better way to handle it would be to use |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
HamzaAmar
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is not recommended, but you could pass them like...
pages/index.js
_app.js
A better way to handle it would be to use
getStaticProps
(orgetServerSideProps
) on yourpages/index.js
and return that flag inprops
and then usepageProps
in your_app
to determine if the flag was set.