stripe / connect-js

Loading wrapper for Connect.js
https://stripe.com/docs/connect/get-started-connect-embedded-components
MIT License
16 stars 6 forks source link

SSR "use client" #128

Open dima-kov opened 3 days ago

dima-kov commented 3 days ago

Is it possible to use @stripe/connect-js/pure in next.js app in client side components ("use client").

Now next.js app raises error:

ConnectJS won't load when rendering code in the server - it can only be loaded on a browser. This error is expected when loading ConnectJS in SSR environments, like NextJS. It will have no impact in the UI, however if you wish to avoid it, you can switch to the `pure` version of the connect.js loader: https://github.com/stripe/connect-js#importing-loadconnect-without-side-effects.

Importing @stripe/connect-js/pure instead of @stripe/connect-js does not help

Any options to make it work?

jorgea-stripe commented 2 days ago

Do you have an example repository/code sample where this error can be reproduced?

dima-kov commented 2 days ago

no really public repo. Found the way to handle this by using dynamic loading:

const Embedded = dynamic<{ code: string }>(
    () => import('_components/Balances').then(mod => mod.Embedded), {
      ssr: false
    });

is it okay way?