Next.js Discord

Discord Forum
it ends upfirst flashing white with the server rendered page then change theme.I'm just confused why this happens since beforeInteractive should mean before next code so before it hydrates and loads code it should change the them. Especially since it was working for me but then stopped working today","dateCreated":"2024-02-24T07:47:11.000Z","answerCount":0,"author":{"@type":"Person","name":"Somali"}}}

Script strategy beforeInteractive doesn't work

Unanswered
Somali posted this in #help-forum
Open in Discord
SomaliOP
Currently I'm trying to modify the body class to change to dark mode before page loads in.
If I put <script type="text/javascript" src="/theme.js" /> in head it works fine,
but if I try to do <Script src="/theme.js" strategy="beforeInteractive"</Script> it ends up
first flashing white with the server rendered page then change theme.

I'm just confused why this happens since beforeInteractive should mean before next code so before it hydrates and loads code it should change the them. Especially since it was working for me but then stopped working today

0 Replies