Google analytics code

Friday, January 23, 2026

Angular / SSR: The document object is not available in this context

Our app was accidentally moved from 18.2.13 to 18.2.14 and SSR stopped working and threw a weird error:


NG0210: The document object is not available in this context. Make sure the DOCUMENT injection token is provided.

A lot of searching really didn't lead me to a good solution. Most solutions will mention that the DOCUMENT object doesn't exist on the server. The problem is this was happening while rendering on the server and I wasn't accessing the DOCUMENT object at all.

Turns out there was a breaking change in 18.2.14 that requires you to update your bootstrap file. There is a new "context" object that is injected into the function that needs to be added as a 3rd argument to the "bootstrapApplication" function.