vercel/next.js · error · Error
Taint can only be used with the taint flag.
Error message
Taint can only be used with the taint flag.
What it means
Thrown by the notImplemented() stub that backs taintObjectReference() and taintUniqueValue() when the experimental React flag (__NEXT_EXPERIMENTAL_REACT) is not enabled. React's experimental_taintObjectReference / experimental_taintUniqueValue are only wired in under that flag; without it the taint APIs are inert stubs that error on use. Taint APIs help prevent leaking sensitive objects/values to the client.
Source
Thrown at packages/next/src/server/app-render/rsc/taint.ts:13
/*
Files in the rsc directory are meant to be packaged as part of the RSC graph using next-app-loader.
*/
import * as React from 'react'
type Reference = object
type TaintableUniqueValue = string | bigint | ArrayBufferView
function notImplemented() {
throw new Error('Taint can only be used with the taint flag.')
}
export const taintObjectReference: (
message: string | undefined,
object: Reference
) => void = process.env.__NEXT_EXPERIMENTAL_REACT
? // @ts-ignore
React.experimental_taintObjectReference
: notImplemented
export const taintUniqueValue: (
message: string | undefined,
lifetime: Reference,
value: TaintableUniqueValue
) => void = process.env.__NEXT_EXPERIMENTAL_REACT
? // @ts-ignore
React.experimental_taintUniqueValue
: notImplemented
View on GitHub (pinned to 0ae8c72462)
Solutions
- Enable experimental React by setting __NEXT_EXPERIMENTAL_REACT=1 (or the project's documented experimental flag mechanism) if you truly need taint.
- If taint is optional, guard its usage behind a feature check and avoid calling it when the flag is off.
- Confirm your React/Next.js versions support the taint APIs before relying on them.
- Remove the taint calls if you do not need the experimental protection.
Example fix
// before
// import { taintObjectReference } from 'next/dist/.../taint'
// taintObjectReference('secret', user) // throws without flag
// after: enable experimental react
// __NEXT_EXPERIMENTAL_REACT=1 next build Defensive patterns
Strategy: type-guard
Validate before calling
// Only call taint when the experimental flag is active.
const TAINT_ENABLED = process.env.__NEXT_EXPERIMENTAL_REACT === '1' || !!process.env.__NEXT_EXPERIMENTAL_REACT
if (TAINT_ENABLED) taintObjectReference('secret', obj) Type guard
function isTaintAvailable(): boolean {
return Boolean(process.env.__NEXT_EXPERIMENTAL_REACT)
} Prevention
- Enable __NEXT_EXPERIMENTAL_REACT only if you depend on the taint APIs.
- Guard taint calls behind a capability check.
- Confirm your React version supports experimental taint.
- Avoid shipping taint calls in shared libraries that run without the flag.
When it happens
Trigger: Application code imports and calls experimental_taintObjectReference or experimental_taintUniqueValue (the Next.js re-exports taintObjectReference/taintUniqueValue) while __NEXT_EXPERIMENTAL_REACT is falsy. The ternary at taint.ts:19/27 selects notImplemented, which throws on invocation.
Common situations: Using React's experimental taint API in a project without enabling experimental React; a tutorial/library that assumes the flag is set; building a security feature (preventing secrets from reaching client bundles) without the required experimental channel.
Related errors
- @next/font/google failed to run or is incorrectly configured
- @next/font/local failed to run or is incorrectly configured.
- Next.js has blocked a javascript: URL as a security precauti
- @rspack/core is not available. Please make sure the appropri
- > Couldn't find any `pages` or `app` directory. Please creat
AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06).
Data as JSON: /api/errors/f37b7b8a9299f42f.
Report an issue: GitHub.