Migration Guide
June 23, 2024 ยท View on GitHub
Migrating to v3.2
- Server-side targets and wrappers are deprecated.
- Sibling selectors are no longer needed.
- Support for scoped styles is now available.
Migrating from v1 to v2
Major Changes
-
6f17cce: Additional CSS Combinations + Seamless Support for Tailwind
- No changes are required for client-side code as
[data-theme=]selectors continue to function as before. - If you are using
ServerSideWrapper,NextJsServerTarget, orNextJsSSGThemeSwitcher, you need to convertforcedPageselements to objects in the shape of{ pathMatcher: RegExp | string; props: ThemeSwitcherProps }. - Use
resolvedColorSchemefor more robust dark/light/system modes. - Utilize combinations of
[data-th=""]and[data-color-scheme=""]for dark/light theme variants. - Use
[data-csp=""]to style based on colorSchemePreference.
- No changes are required for client-side code as
Minor Changes
-
Support Custom Theme Transitions
- Provide the
themeTransitionprop to theThemeSwitchercomponent for smooth theme transitions. - Use
setThemeSetto simultaneously setlightThemeanddarkTheme.
- Provide the
Motivation:
To achieve server-side syncing, cookies and headers are necessary. This means that this component and its children cannot be static and will be rendered server-side for each request. By avoiding the wrapper, only the NextJsSSGThemeSwitcher will be rendered server-side for each request, while the rest of your app can be statically generated.
Take note of the following when migrating to v2:
- No changes are required for projects not using the
Next.jsapp router or server components, except for updating the cookies policy if needed. - Persistent storage is now implemented using
cookiesinstead oflocalStorage. You may need to update your cookies policy accordingly. - The
NextJsSSGThemeSwitcheris provided as an alternative toServerSideWrapperforNext.js. The wrapper component, which disrupted static generation and enforced SSR, is no longer needed. - Visit With Next.js
approuter (Server Components) for more information.
Migrating from v0 to v1
defaultDarkThemehas been renamed todarkTheme.setDefaultDarkThemehas been renamed tosetDarkTheme.defaultLightThemehas been renamed tolightTheme.setDefaultLightThemehas been renamed tosetLightTheme.
with ๐ by Mayank Kumar Chaudhari