koenbok / Framer

Framer - Design Everything
https://framer.com
MIT License
5.83k stars 477 forks source link

How to fix Gatsby.js build error 'window is not defined' ? #590

Open pstakashi opened 3 years ago

pstakashi commented 3 years ago

I started with 'gatsby new' command building a gatsby site, and added a framer component to index.js just like:

import React from "react"
import { Link } from "gatsby"

import Layout from "../components/layout"
import Image from "../components/image"
import SEO from "../components/seo"
import {Frame} from 'framer';

const IndexPage = () => (
  <Layout>
    <SEO title="Home" />
    <Frame>
      Test
    </Frame>
  </Layout>
)

export default IndexPage

After executed 'gatsby build', this error occured.

WebpackError: ReferenceError: window is not defined

I could not fix this by solutions in the official doc (https://www.gatsbyjs.org/docs/debugging-html-builds/).

Anyone can help?

fredericrous commented 3 years ago

I'm getting the same issue on NextJS. I think that's because serverside rendering is activated. I personally don't want to deactivate ssr