1

Recently I began transitioning my personal website from CRA to NextJS and have largely had no issues, but am a bit stuck on this error.

My site has a dynamic background that relies heavily on client-side window properties; given NextJS' SSR defaults I've isolated all references to window size in a single component, and dynamically import it with SSR disabled. I only reference the component in a single place, imported using:

const DynamicBG = dynamic(() => import('./landingSections/FramerBG'), {
ssr: false,
})

The application behaves as expected when ran through npm run dev but refuses to compile through npx next build due to the references to client window size in my code, despite those files being imported with SSR disabled. Am I supposed to differentiate client-rendered components in some way outside dynamic importing?

1
  • 2
    Can you share the code of your component? Commented Aug 5, 2022 at 1:44

1 Answer 1

0

I had the same problem. Resolved by moving out my component from the pages/ folder. All the components of this folder are being built my next with ssr on even if you try to disable it.

Sign up to request clarification or add additional context in comments.

1 Comment

Instead of simply providing the answer directly, try writing a detailed comment that explains the solution, as long as the explanation is not too lengthy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.