Zum Inhalt springen
Blog

Sanity "options meant for '@sanity/client/stega'" error

Nuxt generate with @nuxtjs/sanity throws "options meant for '@sanity/client/stega'" and a 500, even with stega: false. Causes and a step-by-step fix path.

The Liite team7 Min. Lesezeit

Short answer

A stega option is reaching a Sanity client that was not created from the @sanity/client/stega entry point. Find every place a client is created, remove or disable stega options on the plain clients, make sure only one version of @sanity/client is installed, then do a clean rebuild.

You ran nuxt generate with the Sanity module, deployed the static output, and a route returns a 500. The error reads:

It looks like you're using options meant for '@sanity/client/stega'

You set stega: false and nothing changed.

One caveat first. The only report we found is a single thread on Reddit from July 2024. The poster hit this error and stega: false did not help, and no fix was confirmed. Everything below is a diagnosis path rather than a guaranteed cure, and newer package versions may behave differently.

Why it happens

Sanity's JavaScript client has two entry points. @sanity/client is the plain client. @sanity/client/stega is the same client with stega support. Stega encodes hidden source-mapping data into content strings so visual editing tools can trace where a piece of text came from.

The message reads like a guard: a client created from the plain import received options that belong to the stega build, and it complains. We have not verified the exact check inside the library, so treat that as the most likely reading of the wording, not a documented fact.

Plausible causes in a Nuxt project, most common first:

  • Settings in two places. A stega option is set in one spot (a visual-editing or preview setup, for example) while your stega: false is set somewhere else. The failing client still reads the first.
  • Two clients. The module creates one client and your own code creates another, and only one of them got your change.
  • Duplicate package versions. Two versions of @sanity/client are installed, and the module resolves a different one from the one you configured.
  • Stale build output. A cached .nuxt or .output folder keeps the old configuration alive.

Which of these applies in the Reddit case is not known. Why it shows up as a 500 only on a deployed static route is also unconfirmed. One guess is that the failing call runs while that route is rendered, but that is a guess.

CauseSymptomFix
Stega option in a different config than the failing clientstega: false changes nothingSet it where that client reads it
Own createClient call plus module clientOne client fixed, the other still throwsUpdate both
Two @sanity/client versionsSame error after config changesAlign versions
Stale .nuxt or .outputFix works locally only after cleanupDelete and rebuild

Step-by-step fixes

Work through these in order and rebuild after each change, so you know which one mattered.

1. Read the full stack trace

  1. Run nuxt generate locally.
  2. Find the first frame that points into your project or the Sanity module.
  3. Note which client creation threw. That tells you which config to edit.

2. Find every stega setting

  1. Search the project for stega.
  2. Check nuxt.config, runtime config, app.config, and any .env values that feed them.
  3. Check every file that calls createClient.
  4. Make sure no client built from the plain @sanity/client import has a stega option enabled.

Watch the import

A client created from @sanity/client should not receive stega options at all, including stega: true or a studioUrl meant for the stega build. Removing the option is safer than setting it in a place the client may not read.

3. Put stega: false where the failing client reads it

If the module builds the client from the Sanity block in nuxt.config, set it there. If your own code builds a client, set it in that createClient call. Setting it in one place while another client still has stega enabled matches the symptom you describe.

4. Check for duplicate client versions

  1. Run npm ls @sanity/client, or pnpm why @sanity/client, or yarn why @sanity/client.
  2. If more than one version appears, align them.
  3. Upgrade @nuxtjs/sanity and @sanity/client together, not one at a time.

5. Clear caches and rebuild

  1. Delete .nuxt and .output.
  2. Clear any build cache your host keeps.
  3. Reinstall from the lockfile.
  4. Run nuxt generate again.
  5. Serve the output locally with nuxt preview and open the failing route before you deploy.

6. Use the stega import if you actually want stega

If you intend to use visual editing, don't turn it off. Import the client from @sanity/client/stega and configure it as Sanity's documentation describes, instead of passing stega options to the plain client.

What won't help

  • Setting stega: false once and rebuilding. If it isn't in the config the failing client reads, nothing changes. That is what the poster in the thread found.
  • Redeploying without a clean build. A cached .nuxt or .output folder can carry the old configuration forward.
  • Changing host settings. The error comes from the generate and render step, so reproduce it locally first. A host setting can't fix a client that throws while the site is being built.
  • Upgrading only one package. A newer module with an old @sanity/client, or the reverse, can leave you with two copies and the same error.

Reproduce before you deploy

If nuxt generate succeeds but the deployed route fails, compare the Node version and environment variables between your machine and the build environment. Differences there can change which config the client sees.

Checklist before you try again

  • The stack trace tells you which client creation throws.
  • No client built from the plain import has a stega option.
  • stega: false is set in the config that client actually reads.
  • npm ls @sanity/client (or your package manager's equivalent) shows one version.
  • @nuxtjs/sanity and @sanity/client were upgraded together.
  • .nuxt and .output were deleted before the last build.
  • nuxt preview serves the failing route without a 500.

If nothing works

Search the issue tracker of the @nuxtjs/sanity module for the exact error string. If nothing matches, open a new issue there, or ask in Sanity's community channels. Include:

  • the full stack trace and the exact error text
  • your Nuxt, @nuxtjs/sanity and @sanity/client versions
  • your Sanity config block, with tokens removed
  • the output of the version check from step 4
  • what you already tried
Subject: "It looks like you're using options meant for '@sanity/client/stega'" with nuxt generate

Hi, nuxt generate with @nuxtjs/sanity produces a 500 on a static route with this error:
"It looks like you're using options meant for '@sanity/client/stega'".
Setting stega: false did not change it.

Versions: Nuxt <version>, @nuxtjs/sanity <version>, @sanity/client <version>
Package manager output for @sanity/client: <paste>
Sanity config (tokens removed): <paste>
Stack trace: <paste>
Already tried: searched for all stega settings, aligned versions, deleted .nuxt and .output, rebuilt.

Is a stega option being passed to the plain client by the module, and where should it be disabled?

Common questions

Is the 500 caused by Sanity being down?

Unlikely. The error text looks like a configuration complaint, not a network failure. To rule out an outage, check Sanity's status page, but start with your config.

Do I need stega at all?

Only if you use visual editing or click-to-edit overlays on a preview. For a plain static build with no visual editing, keeping stega off in every client you create is the simplest path.

Why did it work before?

A dependency update may have changed which client the module creates or how it handles options. Compare your lockfile with the last build that worked, and read the release notes of @nuxtjs/sanity and @sanity/client for the versions in between.

Should I still expect this to be broken?

Not necessarily. The evidence is from July 2024, and we could not confirm the state of current releases. Test with the latest compatible versions of both packages before spending hours on workarounds.