angular/packages/platform-server/src
Alan Agius 28926ba92c feat(core): introduce BootstrapContext for improved server bootstrapping (#63562)
This commit introduces a number of changes to the server bootstrapping process to make it more robust and less error-prone, especially for concurrent requests.

Previously, the server rendering process relied on a module-level global platform injector. This could lead to issues in server-side rendering environments where multiple requests are processed concurrently, as they could inadvertently share or overwrite the global injector state.

The new approach introduces a `BootstrapContext` that is passed to the `bootstrapApplication` function. This context provides a platform reference that is scoped to the individual request, ensuring that each server-side render has an isolated platform injector. This prevents state leakage between concurrent requests and makes the overall process more reliable.

BREAKING CHANGE:
The server-side bootstrapping process has been changed to eliminate the reliance on a global platform injector.

Before:
```ts
const bootstrap = () => bootstrapApplication(AppComponent, config);
```

After:
```ts
const bootstrap = (context: BootstrapContext) =>
  bootstrapApplication(AppComponent, config, context);
```

A schematic is provided to automatically update `main.server.ts` files to pass the `BootstrapContext` to the `bootstrapApplication` call.

In addition, `getPlatform()` and `destroyPlatform()` will now return `null` and be a no-op respectively when running in a server environment.

PR Close #63562
2025-09-09 10:57:09 -07:00
..
bundled-domino.d.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
domino_adapter.ts perf(platform-server): speed up resolution of base (#61392) 2025-05-16 09:03:38 +00:00
http.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
location.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
platform-server.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
platform_state.ts refactor(platform-server): Add an ssr benchmark setup. (#57647) 2024-10-04 10:45:22 -07:00
private_export.ts build: move private testing helpers outside platform-browser/testing (#61472) 2025-05-20 10:00:43 +00:00
provide_server.ts fix(platform-server): decouple server from animations module (#59762) 2025-01-29 10:52:18 -08:00
server.ts feat(core): introduce BootstrapContext for improved server bootstrapping (#63562) 2025-09-09 10:57:09 -07:00
server_events.ts feat(core): add event listener options to renderer (#59092) 2024-12-10 13:39:47 -08:00
tokens.ts refactor(platform-server): Add an ssr benchmark setup. (#57647) 2024-10-04 10:45:22 -07:00
transfer_state.ts refactor(platform-server): simplify transfer state serialization tracking (#63525) 2025-09-03 09:15:52 -07:00
types.d.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
utils.ts feat(core): introduce BootstrapContext for improved server bootstrapping (#63562) 2025-09-09 10:57:09 -07:00
version.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00