Closed JoshuaKGoldberg closed 1 year ago
Sounds like this is just a general issue with SSR compatibility with libraries that use browser-only APIs.
Have you looked at https://github.com/gatsbyjs/gatsby/issues/309?
It's not specific to this library, so I'm closing for now.
@nickforddesign I have looked at that 😄 and while the general error isn't specific to this library, the issue is that freezeframe.js accesses the window
object immediately - regardless of the runtime it's working in.
Generally, the solution for getting code that tries to do that is to have it either:
typeof window !== "undefined"
(e.g. https://github.com/gatsbyjs/gatsby/issues/309#issuecomment-302043875)componentDidMount
(e.g. https://github.com/gatsbyjs/gatsby/issues/309#issuecomment-373359887)More recently, globalThis
is also a useful strategy.
Would you be open to any of these changes, and if so, could you please reopen this issue? There is behavior done in this library that makes it difficult to use in frameworks such as Gatsby.
Thanks for clarifying, I will look at this
Thank you very much! I'd be happy to help / send a PR / etc., if it's useful at all.
hi everybody, I'm getting the same error when using next.js. I tried defining
if (typeof window !== "undefined") { new Freezeframe(); }
which removed the 'window not defined error', but now the project is not compiling. Please let me know if you need any further clarification. thank you!
Did anyone manage to find a way around this for gatsby projects.
in general I'd recommend that SSR be skipped for this components, even JSDOM doesn't fully implement the canvas APIs required. So, whatever SRR framework you are using, let it skip freezeframe components.
The project isn't open source 😞 but here's a relevant snippet from a build:
gatsby-log.txt