mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #594] feat: implement next/document with class-based Document and getInitialProps support #695
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#695
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/594
Author: @james-elicx
Created: 3/19/2026
Status: 🔄 Open
Base:
main← Head:opencode/quiet-nebula📝 Commits (5)
8b4ab93feat: implement next/document with class-based Document and getInitialProps support422b602fix: address review comments on next/document getInitialProps38c4587feat(pages-router): render error pages through custom _document with getInitialPropsd9509c4feat(pages-router): implement App.getInitialProps and fix appProps propagation6cd668efix(pages-router): inject client entry script and fix asset preloading📊 Changes
18 files changed (+1050 additions, -129 deletions)
View changed files
📝
packages/vinext/src/client/entry.ts(+7 -3)📝
packages/vinext/src/entries/pages-client-entry.ts(+2 -2)📝
packages/vinext/src/entries/pages-server-entry.ts(+194 -16)📝
packages/vinext/src/index.ts(+1 -1)📝
packages/vinext/src/server/dev-server.ts(+181 -12)📝
packages/vinext/src/server/middleware.ts(+21 -36)📝
packages/vinext/src/server/prod-server.ts(+20 -0)📝
packages/vinext/src/shims/app.ts(+68 -4)📝
packages/vinext/src/shims/document.tsx(+61 -11)📝
packages/vinext/src/shims/next-shims.d.ts(+86 -0)📝
packages/vinext/src/shims/router.ts(+5 -1)📝
playwright.config.ts(+3 -1)📝
tests/__snapshots__/entry-templates.test.ts.snap(+196 -18)➕
tests/e2e/pages-router-prod/document.spec.ts(+47 -0)➕
tests/e2e/pages-router/document.spec.ts(+48 -0)📝
tests/fixtures/pages-basic/next-shims.d.ts(+74 -7)📝
tests/fixtures/pages-basic/pages/_app.tsx(+7 -3)📝
tests/fixtures/pages-basic/pages/_document.tsx(+29 -14)📄 Description
Summary
next/documentshim to export proper TypeScript types (DocumentContext,DocumentInitialProps) and a class-basedDocumentbase class with a defaultgetInitialPropsstatic methoddeclare module 'next/document'types tonext-shims.d.tsso custom_document.tsxfiles type-check correctlygetInitialPropsinto the Pages Router dev server via a newbuildDocumentContexthelper — custom documents can now augment document props (e.g. injecting a theme)_document.tsxto use a class-based document withgetInitialPropsthat adds athemeprop rendered asdata-theme-propon<body>tests/e2e/pages-router/document.spec.ts) that verifies the custom document prop is present in the rendered HTMLTesting
PLAYWRIGHT_PROJECT=pages-router pnpm test:e2e tests/e2e/pages-router/document.spec.ts— 1 passedPLAYWRIGHT_PROJECT=pages-router pnpm test:e2e— 85/85 passed, no regressions🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.