you have several options, and i will list them right below, though i really recommend doing it by yourself if you have the time and resources, it will look better and fill much more natural than using a library (that usually just changes the mix-blend-mode
in your css.
darkmode.js – I believe that they are the most known one.
nighly.js – they claim to have zero-dependencies, this could help you be more protected from dependencies vulnerabilities.
solved How to make dark theme for website with javascript