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 мин чтения
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: falseis 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/clientare installed, and the module resolves a different one from the one you configured. - Stale build output. A cached
.nuxtor.outputfolder 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.
| Cause | Symptom | Fix |
|---|---|---|
| Stega option in a different config than the failing client | stega: false changes nothing | Set it where that client reads it |
Own createClient call plus module client | One client fixed, the other still throws | Update both |
Two @sanity/client versions | Same error after config changes | Align versions |
Stale .nuxt or .output | Fix works locally only after cleanup | Delete 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
- Run
nuxt generatelocally. - Find the first frame that points into your project or the Sanity module.
- Note which client creation threw. That tells you which config to edit.
2. Find every stega setting
- Search the project for
stega. - Check
nuxt.config, runtime config,app.config, and any.envvalues that feed them. - Check every file that calls
createClient. - Make sure no client built from the plain
@sanity/clientimport 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
- Run
npm ls @sanity/client, orpnpm why @sanity/client, oryarn why @sanity/client. - If more than one version appears, align them.
- Upgrade
@nuxtjs/sanityand@sanity/clienttogether, not one at a time.
5. Clear caches and rebuild
- Delete
.nuxtand.output. - Clear any build cache your host keeps.
- Reinstall from the lockfile.
- Run
nuxt generateagain. - Serve the output locally with
nuxt previewand 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: falseonce 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
.nuxtor.outputfolder 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: falseis set in the config that client actually reads.npm ls @sanity/client(or your package manager's equivalent) shows one version.@nuxtjs/sanityand@sanity/clientwere upgraded together..nuxtand.outputwere deleted before the last build.nuxt previewserves 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/sanityand@sanity/clientversions - 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.