gatsbyjs/gatsby · error
Slices are disabled.
Error message
Slices are disabled.
What it means
Thrown by the <Slice> component when process.env.GATSBY_SLICES is falsy at build/runtime. This environment variable gates the entire Slices feature; when it is not enabled, the <Slice> component refuses to render. This is the top-level feature gate — using <Slice> without enabling the feature always fails.
Source
Thrown at packages/gatsby/cache-dir/slice.js:64
// just in case generating additional contextual information fails, we still want the base message to show
// and not show another cryptic error message
try {
additionalContextMessage = `\n\nSlice component "${slicesContext.sliceRoot.name}" (${slicesContext.sliceRoot.componentPath}) tried to render <Slice alias="${props.alias}"/>`
} catch {
// don't need to handle it, we will just skip the additional context message if we fail to generate it
}
throw new Error(
`Nested slices are not supported.${additionalContextMessage}\n\nSee https://gatsbyjs.com/docs/reference/built-in-components/gatsby-slice#nested-slices`
)
} else {
throw new Error(
`Slice context "${slicesContext.renderEnvironment}" is not supported.`
)
}
} else {
throw new Error(`Slices are disabled.`)
}
}
class SlicePropsError extends Error {
constructor(inBrowser, sliceName, propErrors, renderedByLocation) {
const errors = Object.entries(propErrors)
.map(
([key, value]) =>
`not serializable "${value}" type passed to "${key}" prop`
)
.join(`, `)
const name = `SlicePropsError`
let stack = ``
let message = ``
if (inBrowser) {
let fullStack = ``View on GitHub (pinned to 8b06340921)
Solutions
- Set GATSBY_SLICES=true in your environment (e.g. .env.development, .env.production, or CI environment variables) before building.
- If you don't intend to use Slices, remove the <Slice> component usage from your code.
- Ensure the env var is available at build time — Gatsby reads it during `gatsby build` / `gatsby develop`.
Example fix
# before — GATSBY_SLICLES not set, using <Slice> # .env.development # (missing GATSBY_SLICES) # after # .env.development GATSBY_SLICES=true
Defensive patterns
Strategy: validation
Validate before calling
// Check feature flag before using Slice
function isSlicesEnabled() {
return process.env.GATSBY_SLICES === 'true' || process.env.GATSBY_SLICES === true
}
if (isSlicesEnabled()) {
// safe to use <Slice>
} else {
console.warn('Slices are disabled. Set GATSBY_SLICES=true to enable.')
} Prevention
- Set GATSBY_SLICES=true in .env.development and .env.production if using Slices.
- Document the feature flag requirement in your project README.
- Remove <Slice> usage if the feature is not needed.
- Verify the env var is set in CI before the build step.
When it happens
Trigger: A page or component renders <Slice alias='...' />, but the GATSBY_SLICES environment variable is not set (or set to a falsy value) during build. The Slice component's top-level if check fails and throws immediately.
Common situations: Developer copies a <Slice> usage from docs or another project without enabling the feature, the GATSBY_SLICES env var was set in one environment (local) but not another (CI/production), or the feature flag was removed in a Gatsby downgrade.
Related errors
- A required environment variable is missing. Set S3_BUCKET or
- ${REPORTER_PREFIX} Error in custom page filter. If you've cu
- Invalid plugin options for "gatsby-plugin-sitemap":
- Cannot specify both JPG and PNG formats
- A languageExtension needs to be defined as an object. Given
AI-assisted analysis of gatsbyjs/gatsby@8b06340921 (2026-08-13).
Data as JSON: /api/errors/9ab8b15a7a2e4b7c.
Report an issue: GitHub.