Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

191
Views
Importing Libraries In Next.js Which Reference The Window Object

I'd like to import dat.gui in my Next.js project, but when importing it the normal way (import * as dat from "dat.gui), I get the error "window is not defined", so apparently the script references the window object somewhere in the initialization. One way to circumvent this is using dynamic imports, but as far as I understand, this means the code from the library is not bundled in the page build but dynamically imported after the page script loaded and started to execute.

It is basically fine, but might be a little bit slower, and also cumbersome to work with as I need to do everything which references the library after the loading process finished. So I wonder, is it also possible to include a library such a dat.gui in the build without running the initialization on the server? Or is my understanding of dynamic imports totally wrong?

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!