gatsbyjs/gatsby · error

Slice context "${slicesContext.renderEnvironment}" is not su

Error message

Slice context "${slicesContext.renderEnvironment}" is not supported.

What it means

Thrown when the <Slice> component receives a SlicesContext whose renderEnvironment is an unrecognized value — not 'server', 'browser', 'engines', 'dev-ssr', or 'slices'. This means the Slice is being rendered in a context that Gatsby does not know how to handle, indicating an internal misconfiguration or an unsupported rendering pipeline.

Source

Thrown at packages/gatsby/cache-dir/slice.js:59

      return <InlineSlice {...internalProps} />
    } else if (slicesContext.renderEnvironment === `slices`) {
      // we are not yet supporting nested slices

      let additionalContextMessage = ``

      // 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`

View on GitHub (pinned to 8b06340921)

Solutions

  1. Ensure all Gatsby packages are at the same version: `npm ls gatsby` and update mismatches.
  2. Run `gatsby clean` and rebuild to eliminate stale cache-dir code.
  3. If using a custom SSR setup, verify SlicesContext is provided with a valid renderEnvironment ('server', 'browser', 'engines', or 'dev-ssr').
  4. Report as a Gatsby bug if using standard configuration — include the renderEnvironment value from the error message.
Defensive patterns

Strategy: validation

Validate before calling

// Validate renderEnvironment before rendering Slices in custom SSR
const VALID_ENVS = ['server', 'browser', 'engines', 'dev-ssr']

function isValidRenderEnv(env) {
  return VALID_ENVS.includes(env)
}

if (!isValidRenderEnv(slicesContext.renderEnvironment)) {
  console.error(`Unknown Slice render environment: ${slicesContext.renderEnvironment}`)
}

Type guard

type SliceRenderEnvironment = 'server' | 'browser' | 'engines' | 'dev-ssr'

function isSliceRenderEnv(env: string): env is SliceRenderEnvironment {
  return ['server', 'browser', 'engines', 'dev-ssr'].includes(env)
}

Prevention

When it happens

Trigger: The SlicesContext.renderEnvironment is set to an unexpected string (or undefined/null due to a missing provider). The Slice component's conditional chain falls through to the else branch and throws. This typically indicates a Gatsby internal issue or a custom SSR setup that provides a SlicesContext with a wrong value.

Common situations: A Gatsby version mismatch between the cache-dir Slice component and the SSR/static-entry that sets the context, a custom SSR renderer that wraps Slice rendering without setting renderEnvironment correctly, or an experimental Gatsby feature that introduced a new environment without updating the Slice handler.

Related errors


AI-assisted analysis of gatsbyjs/gatsby@8b06340921 (2026-08-13). Data as JSON: /api/errors/d37b31bcfb9ee14c. Report an issue: GitHub.