title: how can i use context API and getserversideprops in nextjs
body: <p>am trying to call the currency according to the properties given in the context API, but whenever i call it will get Error: TypeError: Cannot read properties of null (reading 'useContext'). but when call it in my home page without passing it to getServerSideprops is working fine. please can someone help me out to fix this issue</p>
  <p>import {CryptoState} from &quot;../context/cryptoContext&quot;
  import { useContext } from &quot;react&quot;;</p>
  <pre><code>const GetCurrency = async () =&gt; {
      const {currency } = await useContext(CryptoState)
      return currency
  }
  
  export default GetCurrency
  
  
  import Head from 'next/head'
  import GetCurrency from '../components/getCurrency';
  
  
  export default function Home(jsonData) {
  
    console.log(jsonData)
  
    return (
      &lt;div className=&quot;bg-green-100 dark:bg-gray-800 pb-5 h-screen w-screen&quot;&gt;
        &lt;Head&gt;
          &lt;title&gt;Crypto&lt;/title&gt;
          &lt;meta name=&quot;description&quot; content=&quot;Generated by create next app&quot; /&gt;
          &lt;link rel=&quot;icon&quot; href=&quot;/favicon.ico&quot; /&gt;
        &lt;/Head&gt;
  
      &lt;/div&gt;
    )
  }
  
  export async function getServerSideProps(context) {
    const currency = await GetCurrency();
  
    const response = await fetch(`https://api.coingecko.com/api/v3/coins/markets?vs_currency=${currency}&amp;order=gecko_desc&amp;per_page=10&amp;page=1&amp;sparkline=false&amp;price_change_percentage=24h`)
  
    return {
      props: {
        jsonData,
      },
    }
  }
  </code></pre>