Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Window object not defined when accessing MyAlgo Wallet from Next.js SSR project #5

Closed
aetherplex opened this issue Nov 12, 2021 · 7 comments

Comments

@aetherplex
Copy link

The window object is not defined when instantiating a new instance of the MyAlgo class, even if a typeof window !== 'undefined' check is done beforehand on the client side. I think all calls to window should be wrapped in a similar check in case the Communication Bridge is accessed from the server side.

@aetherplex
Copy link
Author

I should mention, I've opened this issue on the communication-bridge repo because the error I was thrown was coming from line 144 in the lib/messenger.js file when the message event listener is added to the window object.

@mxmauro
Copy link

mxmauro commented Nov 12, 2021

Hi @daoarchitect the bridge is not intended to be used from a backend or server-side rendering.

Can you give us some background on the project and why the code is loaded in the server side portion?

@aetherplex
Copy link
Author

Hey @mxmauro, looks like this was a Next.js-specific. I solved it by loading the component that was using the MyAlgo class dynamically using Next.js's Dynamic Import feature.

@Alex99y
Copy link
Contributor

Alex99y commented Apr 19, 2022

Hello @scottbolasevich . Install the latest version of MyAlgo Connect. Import it normally, and instantiate the class inside an useEffect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@mxmauro @Alex99y @aetherplex and others