Code Monkey home page Code Monkey logo

Comments (8)

r00dY avatar r00dY commented on July 1, 2024 4

@Jwhiles sorry for silence.

It's very simple. I have ecommerce in next.js and want to quickly create custom Contentful extension. The easiest way for me to do this is to create new page in my next app (/__contentful-field-extension) - this page will be Contentful extension. Setting up totally separate environment only for the purpose of small Contentful extension is annoying.

Frameworks like next.js are "SSR-first" and you can't prevent next from doing SSR. And it doesn't apply only to next, it applies to most modern next-like frameworks (Gatsby, nuxt).

The fix is super simple, you must assume that window can be undefined and let the app build. If window is undefined you can assume you're on the server and you can do "nothing". It would help a lot.

from ui-extensions-sdk.

petergray-maker avatar petergray-maker commented on July 1, 2024 2

@andipaetzold @Jwhiles
I too am hitting the same issue and I feel that it should be fixed on contentfuls side and not force the break of SSR.
Otherwise you're forcing the issue over to developers to apply the same work around again and again, when it could be simply fixed where the problem actually arises.

As @r00dY points out, it would really help out a lot!
Many thanks

from ui-extensions-sdk.

Jwhiles avatar Jwhiles commented on July 1, 2024

@r00dY can you explain what you would expect to happen in the case where there is no window is accessible? Fundamentally the purpose of this library is to allow the transfer of data from the Contentful User Interface into an iframe and back again. And as a result it's not clear to me what the use case is for calling the init method in an SSR context.

from ui-extensions-sdk.

andipaetzold avatar andipaetzold commented on July 1, 2024

Closing because of inactivity. Feel free to reopen if you are still running into issues.

from ui-extensions-sdk.

jeffyamada avatar jeffyamada commented on July 1, 2024

@Jwhiles it could just do nothing, or bail - this only ever happens on server for SSR (not applicable for a Contentful Extension of course, but in my case and many others I suspect, the extension lives on a server used for the frontend as well.

I'm not super familiar with how the sdk works - but I can't run it at all on this Next.js project because simply importing it causes it to fail completely

from ui-extensions-sdk.

andipaetzold avatar andipaetzold commented on July 1, 2024

Hey folks,

this issue has been resolved with our latest release (v4.8.1). When importing the App SDK, window should not be used anymore and youshouldn't see any error in Node. Please reopen this ticket if you are running into the same problem.

from ui-extensions-sdk.

r00dY avatar r00dY commented on July 1, 2024

@andipaetzold appreciate this, thank you! 💪

from ui-extensions-sdk.

andipaetzold avatar andipaetzold commented on July 1, 2024

@r00dY did this change work for you? I am waiting for some positive feedback before shipping this to everyone as it changes some internal flows.

from ui-extensions-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.