title: How to fetch data in next.js context?
body: <p>Is there any way to fetch data with getStaticProps? I would like to have data in context so I can manipulate it there but I would also like to know if there is solution for future projects.</p>
  <pre><code>import React, { useEffect, useState } from &quot;react&quot;;
  const ShopContext = React.createContext();
  
  
  export const ShopContextProvider = ({ children }) =&gt; {
  
   
      const [addedToCart, setAddedToCart] = useState([]);
      const [amount, setAmount] = useState(0);
  
      const addToCart = (item) =&gt; {
  
          setAddedToCart(prev =&gt; [...prev, item])
  
          addedToCart.map(added =&gt; {
              if (added.id === item.id) {
                  setAddedToCart(addedToCart); 
              }
          })
      }
  
      const removeItem = (item) =&gt; {
          setAddedToCart(addedToCart.filter(added =&gt; added.id !== item.id));
      }
  
      const increaseAmount = (item) =&gt; {
          setAmount(prev =&gt; prev + 1);
      }
  
  
      useEffect(() =&gt; {
          localStorage.setItem('cartItems', JSON.stringify(addedToCart));
      }, [addedToCart])
  
  
      return (
          &lt;ShopContext.Provider value={{ addedToCart, addToCart, amount, increaseAmount, removeItem, setAddedToCart }}&gt;
              {children}
          &lt;/ShopContext.Provider&gt;
      )
  
  }
  
  
  
  export default ShopContext;
  
  </code></pre>