kamyg
kamyg6mo ago

Which components exactly should be islands?

Hi! I am currently developing a web app using fresh and I am getting confused about the usage of islands. In the doc it is stated that:
Islands enable client side interactivity in Fresh. Islands are isolated Preact components that are rendered on the server and then hydrated on the client. This is different from all other components in Fresh, as they are usually rendered on the server only.
Islands enable client side interactivity in Fresh. Islands are isolated Preact components that are rendered on the server and then hydrated on the client. This is different from all other components in Fresh, as they are usually rendered on the server only.
However, this is still kind of a vague description for me. Is this the same as: "every component that renders jsx elements with an event handler attached or uses any browser API"? Is there any tool/linter to help me with deciding which components should be an island?
1 Reply
marvinh.
marvinh.6mo ago
Use an island component whenever you expect javascript to be executed in the browser. Things like attaching event listeners and other things need to happen inside the server, so those components make perfect islands