Dark mode is easy to start.

It is harder to ship cleanly.

Most implementations need to handle:


light mode
dark mode
system preference
stored user preference
a toggle button
no flash of the wrong theme on page load


The flash is the annoying part.

You save the user's choice in localStorage, but your app JavaScript usually runs after the...