Next.js How to get query object in getInitialProps for server side rendering

By default, query object in the request url will not be passed into getInitialProps method on server side rendering. So what u need to do is manually passed in on render server(express or other server)when resolving the a url before getInitialProps  kicked in, like:

server.get('/search', (req, res) => {

  return app.render(req, res, '/search', req.query);


Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *