"_document.js" ctx
query returns 2 objects
#15451
-
Am quite new to Next.js so please help with my understanding. I am in my
We have a page called
Hence, when I do my api call passing the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hi @avaguerrero. For site wide data, using |
Beta Was this translation helpful? Give feedback.
-
Hi @jamesmosier thanks for the reply and it answered my question. I just have a follow up. The reason I need to do the api call is to inject a Google Tag Manager code (coming from our server) into the page's I was able to make this api call if I do it on Are you able to point me into the right direction on how to go about implementing this? Thank you! |
Beta Was this translation helpful? Give feedback.
Hi @avaguerrero. For site wide data, using
_app.js
is recommended._document
'sgetInitialProps
is only executed on the server so utilizing_app
would be better to ensure you get the correct slug as well as allowing it to execute both on the server and client (depending on how you navigated to a page).