Engineering Decisions · Junior · Question 1 of 12
A server-rendered site lets guests pick a dark theme. The very first HTML must already use the right theme, with no flash. Where do you keep the choice?
- 1In a cookie the server reads on each request
- 2In a user settings table in the database
- 3In
localStorage, read by a client effect
Show the answer
Correct answer: In a cookie the server reads on each request
Explanation
Only a cookie reaches the server with the request, so the HTML can be rendered in the right theme straight away. localStorage fits client-only apps, or if a small inline script may set the theme before paint. A database table fits signed-in users who want the setting on every device, but guests have no account.