Question presented to candidate: "We wrap an old jQuery charting plugin in an Angular component. Since turning on SSR it throws NG0500 during hydration and the page stops working. How do you use ngSkipHydration to fix this, and what does it cost?"
What a strong answer should cover:
- Why the plugin breaks hydration: it changes the DOM outside Angular, so the browser DOM no longer matches the server map (NG0500).
ngSkipHydrationon the component host (template attribute orhostmetadata) skips hydration for that component and its whole subtree.- What happens instead: server HTML is shown, then that subtree is discarded and re-rendered in the browser.
- Limits: only on component hosts (NG0504 otherwise), static attribute only (not a binding), and its presence is what counts.
- Costs: no node reuse, no event replay inside it; possible flicker for that island.
- Better fixes to try first: move plugin init to
afterNextRender, fix invalid HTML, use@deferfor browser-only widgets.
Clarifying questions expected:
- "Does the plugin need to run on the server at all, or only in the browser?"
- "Is it one component, or several places using the same widget?"
Code / implementation expected: Yes β a component with ngSkipHydration, ideally both the template and the host metadata form.