Guide

Troubleshooting

Common problems and what to do about them.

The skeleton never shows

The request is holding up the page, so by the time it renders the data is already there. Two common causes:

  • useFetch without lazy: true, server: false: the server waits for the response and sends the content in the HTML. If that's fine, no skeleton is needed.
  • An async wrapper around useFetch. Awaiting it in setup waits for the response too. Keep the wrapper synchronous and return the useFetch result as it is:
composables/useApi.ts
// Not async: the caller gets data, status and error at once and passes them to :of
export const useApi = <T>(path: MaybeRefOrGetter<string>) =>
  useFetch<T>(path, { baseURL: '/api', lazy: true, server: false })

Nothing changed after updating the package

Restart the dev server. Vite keeps transformed modules from node_modules in memory and doesn't watch them, so a reinstalled package keeps serving the old code until a restart.

A shape remembered before the update is still drawn the old way until the content loads once and saves it again. To see the new drawing right away, call forgetSkeletons() or clear the boneprint key in localStorage.

The page jumps when content arrives

Turn on the debug overlay to see where the shape came from and how far the content moved. Most often the sample is shorter or longer than the real data, so give it text of typical length.

An image moves when it loads

It had no size until it loaded, so the skeleton had no room for it. Give it a width and height, or an aspect-ratio.

Something is drawn the wrong way

Use data-skeleton-block to draw an element as one block and data-skeleton-skip to leave it out. For a chart or a logo, use the #skeleton slot.

Three gray lines

There was nothing to measure. Pass a sample, or an id so the shape can be remembered. In development, the console prints a ready-made sample once the first response arrives.

Lines shift as a web font loads

Skeletons measure again when fonts finish loading, so the first frame uses the fallback font. Preload the font to measure it from the start.

A Content Security Policy blocks the script

With Nuxt, the skeleton is drawn before hydration by one inline script. Set a per-request nonce in a server middleware, and the script picks it up:

server/middleware/nonce.ts
export default defineEventHandler((event) => {
  event.context.nonce = createNonce() // the same value as in your CSP header
})

Testing

jsdom and happy-dom have no layout, so there is nothing to measure. While loading, the sample's text is in the document inside an aria-hidden skeleton: queries by role skip it, queries by text don't.