@@ -7,6 +7,8 @@ export interface CoreProps {
77 t ?: string ;
88 /** The nonce value for your Content Security Policy. */
99 nonce ?: string ;
10+ /** dp -> Do Not Persist. Set this prop when you do not want to persist the mode. e.g., when using Tailwind, but you prefer SSG */
11+ dp ?: boolean ;
1012}
1113
1214/** Modify transition globally to avoid patched transitions */
@@ -36,8 +38,8 @@ const modifyTransition = (themeTransition = "none", nonce = "") => {
3638 *
3739 * @source - Source code
3840 */
39- export const Core = ( { t, nonce } : CoreProps ) => {
40- const [ { m : mode , s : systemMode } , setThemeState ] = useStore ( ) ;
41+ export const Core = ( { t, nonce, dp } : CoreProps ) => {
42+ const [ { m : mode , s : systemMode } , setThemeState ] = useStore ( dp ) ;
4143 const resolvedMode = mode === SYSTEM ? systemMode : mode ; // resolvedMode is the actual mode that will be used
4244
4345 useEffect ( ( ) => {
@@ -73,8 +75,8 @@ export const Core = ({ t, nonce }: CoreProps) => {
7375 } ) ;
7476 restoreTransitions ( ) ;
7577 // System mode is decided by current system state and need not be stored in localStorage
76- localStorage . setItem ( COOKIE_KEY , mode ) ;
77- if ( serverTargetEl )
78+ ! dp && localStorage . setItem ( COOKIE_KEY , mode ) ;
79+ if ( ! dp && serverTargetEl )
7880 document . cookie = `${ COOKIE_KEY } =${ resolvedMode } ;max-age=31536000;SameSite=Strict;` ;
7981 } , [ resolvedMode , systemMode , mode , t , nonce ] ) ;
8082
0 commit comments