Closed BhargavGanesh027 closed 9 months ago
Same issue
@BhargavGanesh027 @marcshilling This is a nextjs error faced when using the client side rendering. The clevertap module needed to be initialized in useEffect for it to work. Kindly go through the sample Nextjs web app , using clevertap-web-sdk https://clevertap-next-demo.vercel.app/ Repo Link - https://github.com/KambleSonam/clevertap-next-demo
thanks, it resolves our issue
The solution is working on individual pages but not in app.js . We are getting same error.
error - ReferenceError: HTMLElement is not defined
package.json
"clevertap": "^1.3.0",
"clevertap-web-sdk": "^1.6.9",
app.js
const [clevertapModule, setClevertapModule] = useState(null);
...
...
useEffect(() => {
clevertapInit()
}, []);
...
...
const clevertapInit = async () => {
let clevertap = clevertapModule
if (!clevertap) {
clevertap = await initializeClevertap()
}
};
...
...
async function initializeClevertap() {
const clevertapModule = await import('clevertap-web-sdk');
clevertapModule.default.init("************");
clevertapModule.default.privacy.push({ optOut: false });
clevertapModule.default.privacy.push({ useIP: false });
clevertapModule.default.setLogLevel(3);
return clevertapModule.default;
}
I have same issue too
I am using the clevertap-web-sdk for a company project on next-js
This is the error i get when i try to run the app
Initialising it like this
Version
Please let me know if any other information is needed