DEV Community

Discussion on: The Perfect Dark Mode

sreetamdas profile image
Sreetam Das Author • Edited on

I really didn't want to resort to cookies šŸ˜¬
and to persist this setting on SSR would mean needing to keep a DB I think? I'm open to other suggestions if you've got any!

stativka profile image
Eugene Stativka

No DB involved. You parse cookies during SSR and add the data-theme attribute on the server. On the client you update cookies every time you change the setting.