Visitar URL original
next.config.js: exposeTestingApiInProductionBuild | Next.js
Skip to content
This page is also available as Markdown: request this page's URL with an Accept: text/markdown header. For an index of Next.js documentation, see /docs/llms.txt.

exposeTestingApiInProductionBuild

This feature is currently experimental and subject to change, it's not recommended for production. Try it out and share your feedback on GitHub.
Last updated October 6, 2026

experimental.exposeTestingApiInProductionBuild includes the Instant Navigation testing API in a production build. The instant() helper from @next/playwright uses this API to pause request-time content while an end-to-end test asserts on the UI available immediately.

Enable the option only for a dedicated test build:

next.config.ts
import type { NextConfig } from 'next'
 
const exposeTestingApi = process.env.EXPOSE_TESTING_API === '1'
 
const nextConfig: NextConfig = {
  cacheComponents: true,
  experimental: {
    exposeTestingApiInProductionBuild: exposeTestingApi,
  },
}
 
export default nextConfig

Set the condition when running next build, then serve that build with next start:

Terminal
EXPOSE_TESTING_API=1 pnpm build
pnpm start

Setting the condition only for next start does not add the testing API to an existing build.

Reference

ValueBehavior
false or unsetExcludes the testing API from production builds. This is the default.
trueIncludes the testing API in the production build.

The option requires cacheComponents. Development builds expose the testing API automatically when Cache Components is enabled.

Good to know: Do not enable this option for a user-facing production deployment. Restrict it to local production builds, preview deployments, or other environments used for end-to-end tests.

Version History

VersionChanges
v16.2.0experimental.exposeTestingApiInProductionBuild introduced.

Was this helpful?

supported.