Testing the package is simple:
pnpm run dev
from the playground directory orpnpm playground:dev
from the root directory- Open the browser at
http://localhost:4321
- Set prefers-color-scheme to dark and see if the background is changes when the page reloads and ensure there is no FOUC when reloading
- Create a local storage item with the key
theme-test
and set it todark
. See if the background changes immediately when theincludeStorageListener
option istrue
, or when refreshing the page when it'sfalse
- Change the
localStorageKey
option inastro.config.mts
and see if it still works, try testing with the default value ofthemeToggle
Tip
astro-fouc-killer
will log to the console which scripts were injected. When includeStorageListener
is set to true
(default), the local storage listener will also be injected, otherwise it will be omitted and only the FOUC killer script will be injected.
Inside of your Astro project, you'll see the following folders and files:
/
├── public/
│ └── favicon.svg
├── src/
│ ├── components/
│ │ └── Card.astro
│ ├── layouts/
│ │ └── Layout.astro
│ └── pages/
│ └── index.astro
├── astro.config.mts
└── package.json
All commands are run from the playground directory:
Command | Action |
---|---|
pnpm install |
Installs dependencies |
pnpm run dev |
Starts local dev server at localhost:4321 |
pnpm run build |
Build your production site to ./dist/ |
pnpm run preview |
Preview your build locally, before deploying |
pnpm run astro ... |
Run CLI commands like astro add , astro check |
pnpm run astro -- --help |
Get help using the Astro CLI |