NextJs application that will show in an iframe
Unanswered
Oriental Cuckoo posted this in #help-forum
Oriental CuckooOP
Hi! I am building a NextJs application that will likely show in an iframe as the canonical use case. The application will need to communicate with the parent browser, for example via methods like
window.top.postMessage(eventData, '*');. Does this mean I should exclusively use client side components? I saw client side components have access to browser APIs (https://nextjs.org/docs/app/building-your-application/rendering/client-components#benefits-of-client-rendering), but also know the server side components have faster rendering. Thanks!3 Replies
You cannot use server side components for what you wish to accomplish. Server side components can not contain client logic. Client components are still pre-rendered on the server but after they are hydrated on the client.... Dont put too much thought into which to use. You can intermingle them and nest them as needed.
Oriental CuckooOP
Thanks for the reply! Just confirming that client side components do still have access to browser APIs like
window.postMessage though, right?Yes of course. Server components dont have access to browser api's.