title: Netlify deploy has error: WebpackError: ReferenceError: window is not defined
body: <p>When deploying my gatsby site to Netlify I get this error:
  WebpackError: ReferenceError: window is not defined
  Here is my code:</p>
  
  <pre><code>import React, { useState } from "react";
  import { Link } from "gatsby";
  
  // components
  import Layout from "../components/Layout/Layout";
  import SEO from "../components/seo";
  
  // css
  
  export default function IndexPage() {
  // i took out my strip id so I could post online
    const stripe = window.Stripe("stripeID_Here");
    const [sku, setSku] = useState("sku_GKCxZJybZKaHr7");
  
    const placeOrder = () =&gt; {
      stripe.redirectToCheckout({
        items: [
          {
            sku,
            quantity: 1,
          },
        ],
        successUrl: "http://localhost:8000/success",
        cancelUrl: "http://localhost:8000/cancel",
      });
    };
  
    return (
      &lt;Layout&gt;
        &lt;SEO title="Home" /&gt;
  
  
        {/* Popular   */}
        &lt;section id="Popular-items" className="row"&gt;
          &lt;div className="container popular-items"&gt;
            &lt;h2&gt;Check out our most popular items&lt;/h2&gt;
            &lt;article&gt;
              &lt;img src="http://picsum.photos/340/400" alt="SET HAPPENS T-Shirt" /&gt;
              &lt;h3&gt;SET HAPPENS T-Shirt&lt;/h3&gt;
              &lt;select value={sku} onChange={e =&gt; setSku(e.target.value)}&gt;
                &lt;option value="sku_GKCxZJybZKaHr7"&gt;Small&lt;/option&gt;
                &lt;option value="sku_GK8OJSyke6mMrm"&gt;Medium&lt;/option&gt;
                &lt;option value="sku_GKCy45LwrpfmV8"&gt;Large&lt;/option&gt;
              &lt;/select&gt;
              &lt;button onClick={placeOrder}&gt;Buy Me&lt;/button&gt;
            &lt;/article&gt;
          &lt;/div&gt;
        &lt;/section&gt;
        {/* Popular End */}
  
  
      &lt;/Layout&gt;
    );
  }
  </code></pre>
  
  <p>it says error "window" is not available during server side rendering.</p>
  
  <p>so what can I use in place of window?</p>
  
  <p>Everything else works fine.</p>