cloudflare / cloudflare/vinext
Pages Router: custom `_document` (`getInitialProps` / `renderPage` enhancers) not implemented
- Dominant language
- TypeScript
- Stars
- 8.8k
- Forks
- 406
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 120
Description
> *This issue was created by an agent analysing CI failures from the [Next.js Deploy Suite](https://github.com/cloudflare/vinext/actions/runs/26282973805) (vinext `main` vs Next.js `v16.2.6`, 2026-05-22).*
## Problem
Tests for Pages Router custom `_document.js` fail because vinext does not run `Document.getInitialProps` or honor `ctx.renderPage({ enhanceApp, enhanceComponent })`. As a result `` does not receive the expected `html` prop, custom enhancers never run, and nonce/crossOrigin attributes are missing on emitted scripts.
```
Document.getInitialProps did not run; renderPage enhanceApp/enhanceComponent did not run
```
## Estimated Impact
~8 test failures across the deploy suite.
## Affected Test Suites
- `test/e2e/app-document/rendering.test.ts` (8 failures)
## Recommendation
1. **Reproduce first in vinext's own test suite.** Add a Pages Router app with a custom `_document.tsx` exporting `getInitialProps` plus `renderPage({ enhanceApp, enhanceComponent })`. Assert each hook runs and the produced HTML reflects it.
2. **Study `.nextjs-ref/packages/next/src/server/render.tsx`.** Understand the `_document` lifecycle: getInitialProps with `ctx.renderPage`, the enhanceApp/enhanceComponent contract, and how nonce/crossOrigin propagate to emitted `` tags.
3. **Implement the Pages Router `_document` pipeline.** Run `Document.getInitialProps`, support `ctx.renderPage({ enhanceApp, enhanceComponent })`, propagate `nonce` and `crossOrigin` to script tags.
Contributor guide
Assessment
This issue has not been assessed yet.