Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NextJs: Element is not Defined when using Intro.js [duplicate]

Why did I get the following error while using intro.js in next my project?

ReferenceError: Element is not defined <br/>
like image 598
Johannes Avatar asked Nov 18 '25 20:11

Johannes


1 Answers

Because intro.js uses the DOM API and on the SSR your document object model is not available.

You need to dynamically import intro.js into your project and disable ssr for it. Something like this should solve your problem:

// component with your intro.js logic

const Steps = dynamic(() => import('intro.js-react').then(mod => mod.Steps), {
  ssr: false
});
const Hints = dynamic(() => import('intro.js-react').then(mod => mod.Hints), {
  ssr: false
});
like image 192
KomarCorporation Avatar answered Nov 21 '25 09:11

KomarCorporation



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!