You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My app has different themes that are stored in the user's account. How can I fetch the theme on the server side and then set the theme in next-themes? Or does this need to be set into local storage directly?
The text was updated successfully, but these errors were encountered:
Good question. Next-themes doesn't support this in a nice way right now, and it may not need to.
It sounds like you're server-rendering all your pages, so you can just include the theme as a body class with the initial HTML payload (getInitialProps in _document I believe). Then you don't need localStorage or the render-blocking inline script that next-themes injects.
My web app has a combination of server side and client side rendering, and supports multiple themes. The user may have saved theme preference, which needs to be fetched.
If no themes preferences are present for the user, the app will rely on the system defaults.
You're right - maybe I don't need to use localStorage but its useful when it comes to propagating changes across tabs/sessions.
next-themes was really useful for the above reasons. Saved me from the task of building in all that logic.
If only it could support a way to set initial theme. For eg.
Currently., I am fetching the preference on the server side and setting the theme (setTheme()) on the client side, which is causing the frontend to flash.
Thanks for the great library.
My app has different themes that are stored in the user's account. How can I fetch the theme on the server side and then set the theme in next-themes? Or does this need to be set into local storage directly?
The text was updated successfully, but these errors were encountered: