angular/angular
@angular/platform-server
The Node-side platform that powers SSR and static site generation. Renders Angular templates into a Domino-backed DOM, serializes the result to HTML, and emits hydration annotations consumed by the client at boot.
Purpose
@angular/platform-server provides:
- A server-side
Renderer2that targets Domino instead of a real DOM. - The
renderApplicationandrenderModulerendering APIs. provideServerRendering— the standalone-providers entry that registers all SSR-required tokens.- Server-aware integrations for
HttpClient(transferring response state to the client) and the router (initial URL). - The hydration annotation emitter that pairs with the client-side hydration matcher.
Directory layout
packages/platform-server/
├── src/
│ ├── server.ts # platformServer + module exports
│ ├── server_renderer.ts # Renderer2 implementation against Domino
│ ├── render.ts # renderApplication / renderModule
│ ├── transfer_state.ts # Server-side TransferState integration
│ ├── http.ts # SSR-aware HttpClient adapters
│ ├── tokens.ts # SSR-only DI tokens
│ └── ...
├── testing/ # platform-server/testing harness
└── init/ # provideServerRendering and friendsKey abstractions
| Type / function | File | What it is |
|---|---|---|
renderApplication |
packages/platform-server/src/render.ts |
Renders a standalone application to an HTML string. |
renderModule |
same | Legacy module-based equivalent. |
provideServerRendering |
packages/platform-server/src/init/ |
The provider feature consumed by @angular/ssr and custom servers. |
ServerRenderer2 |
packages/platform-server/src/server_renderer.ts |
The Domino-backed Renderer2. |
TransferState integration |
packages/platform-server/src/transfer_state.ts |
Serializes server state into a <script> island. |
INITIAL_CONFIG |
packages/platform-server/src/tokens.ts |
The token holding the initial URL/document for the render. |
How a render works
sequenceDiagram
participant Caller as Express/Vercel handler
participant Render as renderApplication
participant Platform as platformServer
participant App as ApplicationRef
participant Domino as Domino DOM
Caller->>Render: renderApplication(rootCmp, {document, url, providers})
Render->>Platform: createPlatformFactory(serverPlatformProviders)
Platform->>App: createApplication(providers)
App->>Domino: ServerRenderer2 creates DOM nodes
App->>App: tick(); change detection populates the tree
App->>App: serialize TransferState → <script>
App->>App: emit hydration annotations
Render->>Caller: Promise<HTML string>The HTML output includes:
- The fully rendered DOM tree.
- Hydration annotations (data attributes the client matches against).
- A
<script>island holdingTransferStatedata (HTTP responses, custom keys).
SSR integration
@angular/ssr (the smaller wrapper package) re-exports the public surface and adds Express/Hono adapters. Most of the actual SSR logic lives here. The @angular/build package (shipped from the angular/angular-cli repo) is the build-system glue.
Hydration
When the client app boots with provideClientHydration(), the runtime walks the existing DOM, matches the hydration annotations emitted here, and reuses the existing nodes instead of re-creating them. See systems/hydration for the full flow.
Incremental hydration (@defer { … } @hydrate when ...) extends this story: the server emits a "deferred shell" that the client hydrates lazily when the trigger fires.
Integration points
@angular/core— provides the rendering pipeline; this package supplies the renderer factory and SSR-specific tokens.@angular/common/http— usesprovideServerRenderingto swapHttpClientfor an SSR-aware backend that records responses for transfer.@angular/router— receives the initial URL throughINITIAL_CONFIG(or the standalone-equivalent providers) so server navigation is identical to client navigation.- Domino — the DOM library at
angular/domino, pinned bypackage.json. A fork of Mozilla'sdom.jsmaintained by the Angular team.
Testing
platform-server/testing ships a ServerTestingModule and matching bootstrapApplicationServer for tests that need to assert on the rendered HTML or hydration annotations. Examples live in integration/platform-server-hydration.
Migrations
The migration story is largely owned by @angular/ssr (in the CLI repo). Within this package, the historical migration was the move from renderModule to renderApplication for standalone apps.
Entry points for modification
- A new SSR option (e.g., a control over whether to emit a particular kind of annotation): extend
provide_server_rendering.tsand document it in the JSDoc. - A new server-only renderer behavior (e.g., DOM-attribute filtering): extend
server_renderer.ts. - TransferState serialization changes: coordinate with the matching client-side deserialization in
@angular/core.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.