How can I attach scripts?
Unanswered
North Pacific hake posted this in #help-forum
North Pacific hakeOP
I have a simple app and I just want to setup a simple theme change functionality.
When using react + vite, I just used a script like this
When using react + vite, I just used a script like this
const html = document.querySelector("html");
document.addEventListener("DOMContentLoaded", () => {
const theme = localStorage.getItem("theme") ?? "cyberpunk";
html.setAttribute("data-theme", theme);
});
document.addEventListener("theme-changed", (e) => {
console.log(e.detail);
const themeName = e.detail;
html.setAttribute("data-theme", themeName);
})How can I attach a script like that to a nextjs app?