
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
@next/playwright
Advanced tools
> - **Status:** Experimental. This API is not yet stable. > - **Requires:** [Cache Components](https://nextjs.org/docs) to be enabled.
- Status: Experimental. This API is not yet stable.
- Requires: Cache Components to be enabled.
Playwright helpers for testing Next.js applications.
An instant navigation commits immediately without waiting for data fetching. The cached shell — including any Suspense loading boundaries — renders right away, and dynamic data streams in afterward. The shell is the instant part, not the full page.
instant() lets you test whether a route achieves this. While the callback is
active, navigations render only cached and prefetched content. Dynamic data is
deferred until the callback returns. This lets you make deterministic assertions
against the shell without race conditions.
The tool assumes a warm cache: all prefetches have completed and all cacheable
data is available. This way you're testing whether the route is structured
correctly for instant navigation, independent of network timing. If content you
expected to be cached is missing inside the callback, it points to a problem — a
missing use cache directive, a misplaced Suspense boundary, or a similar gap.
Loading shell appears instantly (dynamic content behind a Suspense boundary):
import { instant } from '@next/playwright'
test('shows loading shell during navigation', async ({ page }) => {
await page.goto('/')
await instant(page, async () => {
await page.click('a[href="/dashboard"]')
// The loading shell is visible — dynamic data is deferred
await expect(page.locator('[data-testid="loading"]')).toBeVisible()
})
// After instant() returns, dynamic data streams in normally
await expect(page.locator('[data-testid="content"]')).toBeVisible()
})
Fully instant navigation (all content is cached):
test('navigates to profile instantly', async ({ page }) => {
await page.goto('/')
await instant(page, async () => {
await page.click('a[href="/profile"]')
// All content renders immediately
await expect(page.locator('[data-testid="profile-name"]')).toBeVisible()
await expect(page.locator('[data-testid="profile-bio"]')).toBeVisible()
})
})
In development (next dev), the testing API is available by default. In
production builds, it is disabled unless you explicitly opt in:
// next.config.js
module.exports = {
experimental: {
exposeTestingApiInProductionBuild: true,
},
}
This is not meant to be deployed to live production sites. Only enable it in controlled testing environments like preview deployments or CI.
instant() sets a cookie that tells Next.js to serve only cached data during
navigations. While the cookie is active:
When the callback completes, the cookie is cleared and normal behavior resumes.
The layering between this package and Next.js is intentionally very thin. This serves as a reference implementation that other testing frameworks and dev tools can replicate with minimal effort. The entire mechanism is a single cookie:
// Set the cookie to enter instant mode
document.cookie = 'next-instant-navigation-testing=1; path=/'
// ... run assertions ...
// Clear the cookie to resume normal behavior
document.cookie = 'next-instant-navigation-testing=; path=/; max-age=0'
FAQs
> - **Status:** Experimental. This API is not yet stable. > - **Requires:** [Cache Components](https://nextjs.org/docs) to be enabled.
We found that @next/playwright demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.