Question presented to candidate: "Our marketing site is a client-rendered Angular app and the SEO team says crawlers and link previews see an empty page. What is Angular Universal, or SSR, and what would change if we turned it on?"
What a strong answer should cover:
- Server-side rendering produces the page HTML on a server (per request) or at build time (prerendering / SSG), so the first paint shows real content.
- Angular Universal is the old name; since v17 the tooling lives in the CLI as
@angular/ssr, added withng add @angular/ssr. - Hydration (
provideClientHydration()) lets the browser reuse the server DOM instead of re-creating it, and the HttpClient transfer cache avoids repeating API calls. - Render modes per route:
RenderMode.Server,RenderMode.Prerender,RenderMode.Clientinapp.routes.server.ts. - SSR-safe code: no
window/documentaccess during render; useafterNextRender,isPlatformBrowser,inject(DOCUMENT). - Trade-offs: a Node server to operate (unless fully prerendered), time to first byte, and the security setting
allowedHosts.
Clarifying questions expected:
- "Is the content the same for every visitor, or personalised per request?"
- "Do we already have somewhere to run a Node server, or must this be static hosting?"
Code / implementation expected: Optional β the server config files, and a component that is safe to render on the server.