angular/packages/core/src/application
Alan Agius 6117ccee2e feat(core): introduce BootstrapContext for improved server bootstrapping (#63636)
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.

(cherry picked from commit 8bf80c9d2314b4f2bcf3df83ae01552a6fc49834)

PR Close #63636
2025-09-09 10:45:02 -07:00
..
application_config.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
application_init.ts docs: set syntax highlighting of code examples MD code blocks (#59026) 2024-12-04 17:30:28 +01:00
application_module.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
application_ngmodule_factory_compiler.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
application_ref.ts docs: Deprecate BootstrapOptions on bootstrapModule (#62690) 2025-08-06 11:19:45 +02:00
application_tokens.ts refactor(compiler): Tree shake Element Registry (#62682) 2025-07-23 09:37:16 -04:00
create_application.ts feat(core): introduce BootstrapContext for improved server bootstrapping (#63636) 2025-09-09 10:45:02 -07:00
platform_tokens.ts docs: mark REQUEST and related symbols as stable (#60717) 2025-04-03 13:04:23 -07:00
tracing.ts refactor(core): allow tracing service to wrap event listeners (#59134) 2024-12-12 14:52:42 -08:00