Angular · Senior · Question 27 of 75

How do you safely use browser-only APIs (window, localStorage) in an SSR app?

Explanation

afterNextRender and afterEveryRender never run on the server. For values needed in both environments, use an injectable abstraction with a server and a browser implementation.

Further reading

Problem with a question

Angular · Senior · question 27

Test yourself

Take the Angular · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz