Nuxt3 Composables not available (nuxtjs/sanity)

The site has suddenly stopped working, even though the code has not changed. It’s to do with composables in Nuxt3, specifically, useSanityQuery which comes from the nuxtjs/sanity module.

Site is https://main--museums-aotearoa.netlify.app/

this is the main branch deploy that shows the error, I’ve rolled production back to a build that is currently working.

I’m getting an error: [nuxt] error caught during app initialization ReferenceError: useSanityQuery is not defined

It seems that it can’t find useSanityQuery which is a nuxt composable, provided by nuxtjs/sanity I’ve installed it according to the docs, and generally you shouldn’t need to import useSanityQuery as the composable should be autoimported.

I’ve tried a few things, most relevant are

  1. directly importing, this failed at build time:
    import { useSanityQuery } from "#imports";

  2. updating netlify.toml to include

[functions]
  included_files = [
    "./node_modules/@sanity/client/**/*"
  ]

Any help much appreciated!

Mind providing a minimal reproduction that we can test on our end?

I can’t recreate it in a minimal setup, a new install with pnpm, nuxt and sanity works fine. I am trying a bunch of other things

Bizarre, it magically started working again with the latest deploy.

1 Like

glad to hear it. thanks for writing back in.