I would add this into a table in the database under user preferences since you need the username, avatar, etc. I store important decisions like dark mode in a database table. This would improve the experience if the user switches browsers (depending on your app). It provides continuity without forcing the user to find the dark mode toggle again. Plus, by delivering dark mode from the server, you eliminate flashes, ensuring a smoother experience.