---
title: exposeTestingApiInProductionBuild
description: Expose the Instant Navigation testing API in production builds for end-to-end tests.
url: "https://nextjs.org/docs/app/api-reference/config/next-config-js/exposeTestingApiInProductionBuild"
docs_index: /docs/llms.txt
lastUpdated: 2026-11-17
badge: "Experimental"
prerequisites:
  - "Configuration: /docs/app/api-reference/config"
  - "next.config.js: /docs/app/api-reference/config/next-config-js"
related:
  - /docs/app/api-reference/file-conventions/route-segment-config/instant
  - /docs/app/guides/instant-navigation
  - /docs/app/guides/testing/playwright
---

> For an index of all documentation, see [/docs/llms.txt](/docs/llms.txt).

> This feature is currently experimental and subject to change, it’s not recommended for production. Try it out and share your feedback on [GitHub](https://github.com/vercel/next.js/issues).

Use `experimental.exposeTestingApiInProductionBuild` to include the Instant Navigation testing API in a production build. The [`instant()` helper from `@next/playwright`](/docs/app/guides/testing/playwright#testing-instant-navigations) 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:

**TypeScript**

```ts highlight={3,8} title="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
```

**JavaScript**

```js highlight={1,7} title="next.config.js" 
const exposeTestingApi = process.env.EXPOSE_TESTING_API === '1'

/** @type {import('next').NextConfig} */
const nextConfig = {
  cacheComponents: true,
  experimental: {
    exposeTestingApiInProductionBuild: exposeTestingApi,
  },
}

module.exports = nextConfig
```

Set `EXPOSE_TESTING_API=1` when you build and start the test server.

```bash title="Terminal"
EXPOSE_TESTING_API=1 pnpm build
EXPOSE_TESTING_API=1 pnpm start
```

The server reloads `next.config` at startup, so keep the option enabled when you run `next start`. If you disable the option at startup, `instant()` allows initial page loads to render request-time content while continuing to pause client navigations.

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

## Reference

| Value            | Behavior                                                              |
| ---------------- | --------------------------------------------------------------------- |
| `false` or unset | Excludes the testing API from production builds. This is the default. |
| `true`           | Includes the testing API in the production build.                     |

The option requires [`cacheComponents`](/docs/app/api-reference/config/next-config-js/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

| Version   | Changes                                                      |
| --------- | ------------------------------------------------------------ |
| `v16.2.0` | `experimental.exposeTestingApiInProductionBuild` introduced. |

## Related

Learn how to inspect and test instant navigation.

- [instant](/docs/app/api-reference/file-conventions/route-segment-config/instant): Configure instant navigation validation for a route segment.
- [Instant navigation](/docs/app/guides/instant-navigation): Learn how to structure your app to prefetch and prerender more content, providing instant page loads and client navigations.
- [Playwright](/docs/app/guides/testing/playwright): Learn how to set up Playwright with Next.js for End-to-End (E2E) Testing.

---

For a semantic overview of all documentation, see [/sitemap.md](/sitemap.md)

For an index of all available documentation, see [/docs/llms.txt](/docs/llms.txt)