fresh
fresh copied to clipboard
Feature: Client only lazy loaded island components
For some of the components it does not really make sense to render them on the server (eg they require window object). A similar functionality could be achieved by adding
if (!IS_BROWSER) {
return <div>Loading...</div>;
}
but in the situation I described it would be better if the framework knows that this component is not going to work on the server and avoid the server part completely. Similar to https://nextjs.org/docs/advanced-features/dynamic-import
Every component on the islands will be hydrated on the client (if js is enabled). Wouldn't be easier to in that component, that has a state, to get the condition?
if (!data) return <div>Loading…</div>
Mh, how would this work? What would be rendered in place of the component on the server? I think your IS_BROWSER
example is exactly how I envision that this should work.
Yes, it is not super important and it is solvable. My thinking was that sometimes you don't need the server render part at all so it could be "cheaper on the server" to just skip it.