SSR: ReferenceError: window is not defined
See original GitHub issueDescribe the bug I am testing the new SSR capabilities with next.js and I am seeing:
ReferenceError: window is not defined
at UniversalStorage.setUniversalItem (/node_modules/@aws-amplify/core/lib/UniversalStorage/index.js:88:21)
at UniversalStorage.setItem (/node_modules/@aws-amplify/core/lib/UniversalStorage/index.js:69:22)
at CognitoUser.cacheTokens (/node_modules/amazon-cognito-identity-js/lib/CognitoUser.js:1412:18)
at /node_modules/amazon-cognito-identity-js/lib/CognitoUser.js:1391:17
at /node_modules/amazon-cognito-identity-js/lib/Client.js:127:31
To Reproduce Follow steps in tutorial here https://docs.amplify.aws/start/getting-started/data-model/q/integration/next Connect with auth and sign in with cognito.
Expected behavior
window
is not used on the server.
Issue Analytics
- State:
- Created 3 years ago
- Comments:20 (6 by maintainers)
Top Results From Across the Web
How to resolve window is not defined on npm run serve:ssr ...
The issue is caused by package webpack, I think but not sure. Description. The command line : "npm run serve:ssr" occurred the exception...
Read more >Angular Universal: ReferenceError: window is not defined
This error can be caused by a reference to the Window object if you are rendering your application from a server like Node.js....
Read more >referenceerror: window is not defined SSR ANGULAR
on SSR, there is no window , because you are on the server, not on the browser. So you have to make your...
Read more >referenceerror: window is not defined, how to solve
Here's how to fix the “referenceerror: window is not defined” error that you might have in Node.js or with a tool like Next.js....
Read more >How To Solve ReferenceError window is not defined in ...
If you are specifically working on a Node.js application and still receive this error, it is because the window object does not actually...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Is Authentication on the server made available now?
@m5r At this moment, the supported use-case is
Auth
happening on the client so credentials can be shared with the server.In your example, you’re attempting to do the authentication on the server, which we’re still solving for. That would make it a feature request, but this use-case seems different than what’s happening for @oste.
@oste https://github.com/aws-amplify/amplify-js/issues/6813#issuecomment-695056643 makes it sound like you were specifying a custom storage adapter. That won’t be necessary with
Amplify.configure({ ...awsexports, ssr: true })
.