镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content
infonomicPublic

About

Bulletproof dark theme detection and switching for Next.js (or other SSR frameworks with minor modifications)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Infonomic Theme

Bulletproof dark theme detection and switching for Next.js (or other SSR frameworks with minor modifications)

Implementation

A 'shim'-based Theme detector and switch with zero Flash of Unstyled Content (FOUC).

Our theme detector and switch determines theme settings based on:

  1. preferences in localStorage,
  2. prefers-color-scheme user agent,
  3. followed by a default theme in that order.

We use localStorage for preferences and NOT cookies as cookies will impact your page caching strategy. You'll need to cache variants of every page for both themes as well as detect cookies in your reverse proxy and page cache mechanics.

Using localStorage however, means we need to use an early-detection JavaScript shim combined with suppressHydrationWarning in our document root HTML element.

Getting started

npm install
npm run dev
# or
yarn install
yarn dev
# or
pnpm install
pnpm dev

Open http://localhost:3000 with your browser to see the result.

License

Infonomic Theme is free software licensed under the MIT license.

For full details, please refer to the LICENSE and COPYRIGHT files in this repository.

Copyright © 2025 Infonomic Company Limited contributors. https://infonomic.io

Major Contributors

About

Bulletproof dark theme detection and switching for Next.js (or other SSR frameworks with minor modifications)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages