Troubleshooting for SvelteKit
Common CookieYes setup problems, like a banner that never shows or scripts loading before consent, and the one line to check for each.
Most problems here are a setup detail, and several show no error at all. Find what you see in the table; each row is one line to check.
Find your symptom
| What you see | Cause | Fix |
|---|---|---|
| The banner never appears | You already chose in this browser, or closed it in this page view | Delete the cookieyes-consent cookie and reload, see Reset and re-test |
| The banner never appears, no error anywhere | <CookieYesRoot> is not in src/routes/+layout.svelte | See Installation → Common mistakes |
loadConsent() found no event.locals.cookieyes in the server log | The handle is not exported from src/hooks.server.ts | Export handle = cookieyesHandle(config), or combine it with yours through sequence() |
A component or hook throws could not find CookieYes | It is not rendered inside <CookieYesRoot>, or a hook was called outside a component's initialisation, such as in an event handler | Render the page through {@render children()} inside <CookieYesRoot>, and call hooks at the top of a component's <script>, see Console messages |
| The preferences dialog is unstyled, the banner is fine | Only the inlined critical CSS applied: the full stylesheet did not load | Check the request to /cookieyes/styles.css, or your stylesHref, in the Network tab. The route is src/routes/cookieyes/styles.css/+server.ts |
| Do Not Sell does nothing | <CookieOptOut /> is not rendered | <CookieYesRoot> renders it only when regulation, region.strictest or a region.map value is "CCPA". In your own ui snippet, render it yourself |
| Customise or your own "Cookie settings" link does nothing | <CookiePreferences /> is not rendered | Your own ui snippet replaces the default components. Render it in the snippet |
| A tracker loads when a switch is flipped, before Save | You read the live values | Use useConsentCategory() or committedCategories, see useConsent |
| A value from a hook never updates | You destructured the object a hook returned, which reads each field once | Read the fields in the template or a $derived, see useConsent |
| A custom category is missing | Your categories list was rejected; the console says why | See Configuration → Consent categories |
| The banner is in English although you set a language | The language is not in i18n.messages | Import the catalogue, see Translations |
| The recall button is an unstyled circle | class replaced its default class | Add cy-widget to your class |
| The banner flashes and vanishes for returning visitors | The page's HTML is the same for every visitor: a prerendered page, an adapter-static build, or <CookieYesRoot> without state | Pass state={data.consent} from loadConsent. On a prerendered page it is expected: the browser hides the banner after hydration |
| Your CSS rule does nothing | A theme value sets the same property inline, or your selector loses to the SDK's | See Custom CSS |
A rule in a component's <style> block never reaches the banner | Svelte scopes that block to the component's own elements | Use a global stylesheet with data-cy-part selectors, or :global(...) |
| Tracking continues after the visitor withdraws consent | A script that already ran cannot be unloaded | Render ReloadNotice |
| Every returning visitor is asked again | You changed a category id, or which one is required | Expected. See CookiePreferences |
| A checkbox in your own dialog turns on but never off | onchange={toggle} passes the event | Use onchange={(e) => toggle(e.currentTarget.checked)} |
| Focus jumps to the top of the page when a dialog closes | The dialog was opened through the runtime directly | Open it with useConsentActions().showPreferences() |
| The banner is not where you put it in your code | It moves to the top of <body> so keyboard users reach it first | Expected. See Accessibility |
Console messages
[cookieyes] loadConsent() found no event.locals.cookieyes. Add cookieyesHandle(config) to src/hooks.server.ts.
Thrown on the server by loadConsent when the handle did not run for the request. Export handle = cookieyesHandle(config) from src/hooks.server.ts; with a handle of your own, use sequence(cookieyesHandle(config), yourHandle).
[cookieyes] <CookieYesRoot> needs a `config` prop: the same object cookieyesHandle() takes, imported from one shared module.
<CookieYesRoot> rendered without config. Import it from src/lib/cookieyes.ts and pass it: <CookieYesRoot {config} state={data.consent}>.
[cookieyes] useConsent() could not find CookieYes. Wrap the app in <CookieYesProvider config={...}> and call hooks while a component initialises.
Thrown by every hook and component when it is not rendered inside <CookieYesRoot>, which renders the provider the message names; the name at the start is the one that threw, such as useConsent() or <CookieBanner>. It is also thrown when a hook runs after the component initialised, for example inside an event handler. Render the page through {@render children()} inside <CookieYesRoot>, and call hooks at the top of a component's <script>.
[cookieyes] getCookieYes() found no runtime. Mount <CookieYesProvider config={...}> first.
Thrown by getCookieYes() when it runs on the server or before <CookieYesRoot> mounted. Call it from browser code. See Runtime and server helpers.
[cookieyes] OptOut.* sub-components must be rendered inside <OptOut.Root>.
An OptOut.* piece sits outside OptOut.Root. Move it inside. Preferences.* pieces give the same message about <Preferences.Root>.
[cookieyes] Invalid categories config (...). Falling back to the default five
Your categories list broke a rule; the reason is in the brackets. The built-in five are shown until you fix it.
[cookieyes] `regulation` is set manually, so region detection is ignored.
You set both regulation and region. Keep one.
[cookieyes] no translations for language "..."; staying on "..."
You switched to a language that is not in i18n.messages and has no loadLanguage. Add the catalogue.
[cookieyes] blocked POST https://... (rule "...", category: ...)
Not an error: network blocking stopped a request, as configured. Set logBlockedRequests: false to silence it.
Reset and re-test
Make the banner come back. Delete the cookieyes-consent cookie in DevTools → Application → Cookies, or run this in the console and reload:
document.cookie = "cookieyes-consent=; max-age=0; path=/";Or call useConsentActions().reset() from a button you show only in development.
See the banner from any location. Set regulation: "GDPR" while developing instead of relying on region detection.
Check which version a page runs. In the console:
window.CookieYesSDK; // { version: "x.y.z" }The SDK sets this in the browser on every page where it starts, whether or not the banner shows, so public technology scanners can recognise the SDK. It holds the @cookieyes/core version and nothing else.
Trigger the reload notice. Accept the category, reload so the tool starts, then withdraw it. Rejecting on a first visit never shows it, because nothing was running.
Next steps
- Installation: the three-step setup, with its own common mistakes
- Configuration: every option of
src/lib/cookieyes.ts