https://supertokens.com/ logo
windo handler issue
d

derSuchende

04/10/2023, 10:15 AM
Hello, I got this error on SuperTokens module in windowHandler while building with Next.js my App:
info  - Collecting page data .Error: If you are using this package with server-side rendering, please make sure that you are checking if the window object is defined.
    at getWindowOrThrow (D:\Progetti\OH\SORGENTI\openhospital-portal-mui\patient-portal-ui-next\node_modules\supertokens-website\lib\build\utils\windowHandler\defaultImplementation.js:137:15)
    at Object.getDocument (D:\Progetti\OH\SORGENTI\openhospital-portal-mui\patient-portal-ui-next\node_modules\supertokens-website\lib\build\utils\windowHandler\defaultImplementation.js:291:16)
    [...]
r

rp

04/10/2023, 11:33 AM
hey @derSuchende could you please elaborate?
d

derSuchende

04/10/2023, 11:46 AM
Sorry, what do you mean?
supertokens-website gives error becouse dont'find the window object while buildin my supertokens next.js app with npm run build command
This is the throwed message: Collecting page data .Error: If you are using this package with server-side rendering, please make sure that you are checking if the window object is defined.
r

rp

04/10/2023, 12:43 PM
right. You need to initialise the frontend SDK only if the window object is available.
d

derSuchende

04/10/2023, 3:05 PM
How can I proceed to set window object available?
r

rp

04/10/2023, 3:07 PM
You don’t have to set it, you have to init the frontend SDK only if it’s available. Please see our guides.
d

derSuchende

04/10/2023, 7:28 PM
Thank you