menu

Next.js

A place to chat about Next.js and answer questions. For all other ZEIT products, check this out.

Channels
Team

Need Explanation on getInitialProps Parameters

November 23, 2018 at 8:26am
The Next.js community has a new home. This thread is preserved for historical purposes. The content of this conversation may be innaccurrate or out of date. Go to new community home →

Need Explanation on getInitialProps Parameters

November 23, 2018 at 8:26am
Hello, Next.js community! 👋🏻
I've search the Spectrum threads and GitHub issues, and so far I can't seem to find any explanation or details on the parameters and return values for getInitialProps method. Is there an official API documentation or any kind of reference explaining this? Thanks in advance.

November 23, 2018 at 8:52am
https://github.com/zeit/next.js/ go to the Fetching data and component lifecycle section
Edited
  • reply
  • like
No good docs, nextjs is not well documented
like-fill
1
  • reply
  • like
You can use inspect(ctx) from getInitialProps(ctx) , it's easy to know what's going on.
  • reply
  • like
Especially when you compose multiple getInitialProps , very handy to debug things
  • reply
  • like
https://github.com/zeit/next.js/ go to the Fetching data and component lifecycle section
Yes, the readme already explains what parameters are availavle. But specifically, I need the IDE or editor to understand what exactly the parameters are and their types.
  • reply
  • like
Also, in this part of the readme [1], getInitialProps has these parameters { Component, router, ctx }, which Component and router parameter isn't documented on an earlier part of the readme[2].
  • reply
  • like
You can use inspect(ctx) from getInitialProps(ctx) , it's easy to know what's going on.
inspect()? Where's that from?
  • reply
  • like
const {inspect} = require('util')
like-fill
2
  • reply
  • like

November 26, 2018 at 8:33am
Many thanks to for recommending using util.inspect
  • reply
  • like