title: How to use Coinbase SDK in a Server-Side Rendered app?
body: <p>I was trying to follow the guide here to get user's wallet through Coinbase in my Next.js app:</p>
  <p><a href="https://docs.cloud.coinbase.com/wallet-sdk/docs/initializing" rel="nofollow noreferrer">https://docs.cloud.coinbase.com/wallet-sdk/docs/initializing</a></p>
  <p>But I get this when I tried to render the component with the SDK initiating.</p>
  <pre><code>Server Error
  ReferenceError: localStorage is not defined
  
  This error happened while generating the page. Any console logs will be displayed in the terminal window.
  </code></pre>
  <p><a href="https://i.stack.imgur.com/vJ9CT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vJ9CT.png" alt="enter image description here" /></a></p>
  <p>Is there a proper way to make it work in a server-side rendered app?</p>
  <p>These are the code btw if that matters.</p>
  <pre><code>// Coinbase START
  
  // TypeScript
  import CoinbaseWalletSDK from '@coinbase/wallet-sdk'
  import Web3 from 'web3'
  
  const APP_NAME = process.env.NAME
  const APP_LOGO_URL = process.env.WEBSITE_URL + '/logo.png'
  const DEFAULT_ETH_JSONRPC_URL = 'https://mainnet.infura.io/v3/' + process.env.INFURA_PROJECT_ID
  const DEFAULT_CHAIN_ID = 1
  
  // Initialize Coinbase Wallet SDK
  export const coinbaseWallet = new CoinbaseWalletSDK({
    appName: APP_NAME,
    appLogoUrl: APP_LOGO_URL,
    darkMode: false
  })
  
  // Initialize a Web3 Provider object
  export const ethereum = coinbaseWallet.makeWeb3Provider(DEFAULT_ETH_JSONRPC_URL, DEFAULT_CHAIN_ID)
  
  // Initialize a Web3 object
  export const web3 = new Web3(ethereum as any)
  
  // Coinbase END
  
  </code></pre>
  <p>Related call:</p>
  <pre><code>  function connectCoinBase() {
      console.log('connectCoinBase is triggered');
      if (ethereum &amp;&amp; mounted) {
        setLoading(true);
        ethereum.request({
          method: 'eth_requestAccounts'
        })
        .then((res) =&gt; {
          const accounts: string[] = res as string[];
          if (accounts &amp;&amp; accounts.length) {
            setWalletId(accounts[0]);
            setWalletType(2);
            connectCrypto();
          }
          setLoading(false);
        })
        .catch(err =&gt; {
          console.error('Coinbase eth_requestAccounts failed, error: ', err);
          setLoading(false);
        }) 
      }
    }
  </code></pre>
  <p>The error was thrown without calling this function but happens when this function is added and the page is rendered.</p>
  <p>UPDATE: This error is related to the <code>ScopedLocalStorage</code> class inside the <code>@coinbase/wallet-sdk</code> dependency. The <code>localStorage</code> is not available in server-side rendering.</p>