title: Next.js user get location
body: <p>I want to bring the user location with cloudflare. Localhost and google cloud bring different results. I want to access the location information of the member, not the server. What can I use instead of getStaticProps?</p>
  <p>My Code;</p>
  <pre><code>export async function getStaticProps() {
    const one = await fetch(&quot;https://www.cloudflare.com/cdn-cgi/trace&quot;);
    const two = await one.text();
    var data = two.replace(/[\r\n]+/g, '&quot;,&quot;').replace(/\=+/g, '&quot;:&quot;');
    data = '{&quot;' + data.slice(0, data.lastIndexOf('&quot;,&quot;')) + '&quot;}';
    var locale = JSON.parse(data);
  
    return {
      props: { locale },
    };
  }
  
  function myPage(props) {
     return (props.locale.loc)
  }
  </code></pre>
  <p>solved code;</p>
  <pre><code>  let [locData, setLocData] = useState(&quot;EN&quot;);
    useEffect(() =&gt; {
      fetch(&quot;https://www.cloudflare.com/cdn-cgi/trace&quot;)
        .then((response) =&gt; response.text())
        .then((two) =&gt; {
          var data = two.replace(/[\r\n]+/g, '&quot;,&quot;').replace(/\=+/g, '&quot;:&quot;');
          data = '{&quot;' + data.slice(0, data.lastIndexOf('&quot;,&quot;')) + '&quot;}';
          var locale = JSON.parse(data);
          setLocData(locale.loc);
        });
    }, []);
  </code></pre>