BEFORE_APP_SERIALIZED is an injection token from Angular’s @angular/platform-server package. It lets an application register callbacks that run just before Angular’s server-rendering process serializes the current platform state to a string. Those callbacks may run synchronously or return a promise.
When does the hook run?
Angular calls the registered callbacks near the end of server rendering, immediately before renderApplication or renderModule renders the current platform state to a string. The hook is for work that needs to happen before that serialization step; it is not a general-purpose callback for every stage of application startup or rendering.
As an Amazon Associate I earn from qualifying purchases.
Angular documents the token as a stable API. For version-specific behavior or migration questions, consult the API reference for the Angular version used by your application: Angular BEFORE_APP_SERIALIZED API reference.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsWhat callback forms can you register?
The token’s current type is InjectionToken<readonly (() => void | Promise<void>)[]>. A callback can finish synchronously by returning void, or represent asynchronous work by returning a Promise<void>. Angular’s source-level integration test demonstrates registering callbacks with multi providers, including a promise-based callback: Angular platform-server integration test.
#1 Best Overall
Here is the provider shape, adapted to illustrate the API:
{ provide: BEFORE_APP_SERIALIZED, useValue: () => { /* synchronous work */ }, multi: true }
An asynchronous callback can return a promise:
{ provide: BEFORE_APP_SERIALIZED, useValue: () => doAsyncWork(), multi: true }
Import the token from @angular/platform-server and register providers in the server-rendering configuration appropriate to your application. Check the documentation and declarations for your installed Angular version when adapting the example; the test shows the provider pattern, not a guarantee that every application should use this hook.
Rank #2
When should you use it?
Use the hook only when a particular task must finish immediately before server-rendered platform state is serialized. The key decision is whether that task is synchronous or asynchronous: return directly for synchronous work, or return its promise when completion must be represented asynchronously.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11The API definition establishes the timing and callback contract, but does not by itself recommend a specific production use case or spell out detailed error-handling guarantees. Base those decisions on the needs of your application and the documentation for its Angular version.
Quick Recap
Rank #4
Rank #3
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




