Our application is server side-rendered with an"Islands Architecture".
The general idea of an “Islands” architecture is to render HTML pages on the server, and inject placeholders or slots around highly dynamic regions. These placeholders/slots contain the server-rendered HTML output from their corresponding widget. They denote regions that can then be "hydrated" on the client into small self-contained widgets, reusing their server-rendered initial HTML.
The Islands architecture permits us to add pockets of interactivity to the application. A DOM element becomes the root of that particular interactivity, typically rendering a Preact component.
You can also read more about the Overlaps & Challenges.
With these options, we sometimes need to decide what rendering mechanism to use for the frontend, we advise the usage of:
- Preact for complex interactivity: search bar, autocomplete, multi-autocomplete, post subscription button, accessible colour picker.
The comment subscription component source is an excellent example of this.
The initial potential component state is loaded, a subscribe button. If the user has not subscribed to comments of a post, the Preact component renders, but the VDOM diff determines there is nothing to do, so the server-side rendered markup remains the same. When a user subscribed to post comments and the page loads, the server-side rendered subscribe button renders, and then the comment subscription component renders the button in the unsubscribe state.