title: Pass variables from custom server to components in NextJS
body: <p>I have set up a custom server in NextJS as illustrated <a href="https://github.com/zeit/next.js/#custom-server-and-routing" rel="nofollow noreferrer">here</a> for custom routing.</p>
  <p><strong>server.js:</strong></p>
  <pre><code>app.prepare()
    .then(() =&gt; {
      createServer((req, res) =&gt; {
        const parsedUrl = parse(req.url, true)
        const { pathname, query } = parsedUrl
  
        if (foreignLang(pathname, lang)) {
          app.render(req, res, checkLangAndConvert(links, pageVal, pathname, lang), query)
        } else {
          handle(req, res, parsedUrl)
        }
      })
        .listen(port, (err) =&gt; {
          if (err) throw err
          console.log(`&gt; Ready on http://localhost:${port}`)
        })
    })
  </code></pre>
  <p>it basically maps <code>/en/url</code> to <code>/another_url</code> for i18n.</p>
  <p>I understand I can use <code>query</code> parameter here and read it in the component, but I would like to pass options to the <code>App</code> without rechecking the URL. Is it possible to pass options from server level to app level without reading the URL?</p>
  <p><strong>Edit:</strong> After a bit of investigating the marked answer explained that <code>query</code> actually does not mean query-paramter in the URL, rather than passing a value from the server to client. Misleading word as it indicates only client side action. This was exactly what I needed.</p>