react-social-login icon indicating copy to clipboard operation
react-social-login copied to clipboard

ReferenceError: window is not defined with Next.js during Server Side Rendering (SSR)

Open peZhmanParsaee opened this issue 1 year ago • 6 comments

Hi

react-social-login has just recently updated to v3.4.16 and it has a problem during Server Side Rendering (SSR) with Next.js, because on the server side , window object is not defined , the below error can be seen on the shell during SSR:

image

In addition, I prettified the JavaScript codes of react-social-login located in this folder to know which line the error is :

  • node_modules/react-social-login/dist/social-login.js

In line 8 window object is undefined image

Please this is urgent for us, can you please fix it as soon as possible ?

  • react-social-login : v3.4.16
  • Next.js: v13.0.4
  • Node.js v18

peZhmanParsaee avatar Nov 30 '22 16:11 peZhmanParsaee

Same issue reproducing for me. Even tried the dynamic import for component with option {ssr: false} still getting this error.

  • react-social-login: v3.4.16
  • Next.js: v10.0.5
  • Node.js: v11.15.0

Aravin008 avatar Dec 01 '22 06:12 Aravin008

Could you please revert to .15 version. I will look into this issue. If you have a fix, you can pull a request.

On Thu, Dec 1, 2022, 11:31 AM Aravin008 @.***> wrote:

Same issue reproducing for me. Even tried the dynamic import with option {ssr: false} still getting this error. Production build is also failing.

  • react-social-login: v3.4.16
  • Next.js: v10.0.5
  • Node.js: v11.15.0

— Reply to this email directly, view it on GitHub https://github.com/deepakaggarwal7/react-social-login/issues/238#issuecomment-1333253192, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEU7A3BGRKLW3OHQ2UEZTGDWLA5K3ANCNFSM6AAAAAASPZQREY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

deepakaggarwal7 avatar Dec 01 '22 10:12 deepakaggarwal7

Can you create a minimal failing example using next js on codesandbox or any other online tool (or attach a zip). It will help me replicate and fix it faster. Else, can you go through commit changes between .15 and .16 and suggest what could cause it. There isn't much change that has taken place

deepakaggarwal7 avatar Dec 03 '22 11:12 deepakaggarwal7

Could you please revert to .15 version. I will look into this issue. If you have a fix, you can pull a request.

Thank you, yes I reverted back to version 3.4.15 and everything is fine now.

But also there was an error to revert back to this version, because the previous version does not support React 18, and I finally fix it by overriding peer dependency of react-social-login in package.json of our project and specified React v18.

peZhmanParsaee avatar Dec 04 '22 13:12 peZhmanParsaee

Can you create a minimal failing example using next js on codesandbox or any other online tool (or attach a zip). It will help me replicate and fix it faster. Else, can you go through commit changes between .15 and .16 and suggest what could cause it. There isn't much change that has taken place

Yes I will do this , cheers :)

peZhmanParsaee avatar Dec 04 '22 13:12 peZhmanParsaee

Any update on this? We have the same issue on Gatsby SSR, downgrading to v3.4.15 works for now.

pepijn-vanvlaanderen avatar Jan 09 '23 13:01 pepijn-vanvlaanderen