I'm trying to use the npm package 'split-type' https://www.npmjs.com/package/split-type within next.js but I'm getting the error ReferenceError: Element is not defined. I've tried dynamic importing but this does not let me use splitType in the way it is documented. I have tried both import { SplitType } from "split-type" and import SplitType from 'split-type'.
My Dependencies in package.json
"dependencies": {
"gsap": "^3.10.4",
"locomotive-scroll": "^4.1.4",
"next": "latest",
"react": "17.0.2",
"react-dom": "17.0.2",
"split-type": "^0.3.1"
}
package-lock.json
"node_modules/split-type": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/split-type/-/split-type-0.3.1.tgz",
"integrity": "sha512-GPmSaAMmn9FhpfAypLFnmslx4QFqsW+u4bP47aCphQ+DwAr0ejxoda3XVoI6+CeZeUNlsQC/ftGYq4IojuAkoQ=="
},