Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pages router: Enable strict next/head children reconciler by default #65418

Merged
merged 1 commit into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export function getDefineEnv({
...getImageConfig(config, dev),
'process.env.__NEXT_ROUTER_BASEPATH': config.basePath,
'process.env.__NEXT_STRICT_NEXT_HEAD':
config.experimental.strictNextHead ?? false,
config.experimental.strictNextHead ?? true,
'process.env.__NEXT_HAS_REWRITES': hasRewrites,
'process.env.__NEXT_CONFIG_OUTPUT': config.output,
'process.env.__NEXT_I18N_SUPPORT': !!config.i18n,
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/export/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ export async function exportAppImpl(
serverActionsManifest,
}
: {}),
strictNextHead: !!nextConfig.experimental.strictNextHead,
strictNextHead: nextConfig.experimental.strictNextHead ?? true,
deploymentId: nextConfig.deploymentId,
experimental: {
ppr: nextConfig.experimental.ppr === true,
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/server/base-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ export default abstract class Server<
supportsDynamicHTML: true,
trailingSlash: this.nextConfig.trailingSlash,
deploymentId: this.nextConfig.deploymentId,
strictNextHead: !!this.nextConfig.experimental.strictNextHead,
strictNextHead: this.nextConfig.experimental.strictNextHead ?? true,
poweredByHeader: this.nextConfig.poweredByHeader,
canonicalBase: this.nextConfig.amp.canonicalBase || '',
buildId: this.buildId,
Expand Down
1 change: 1 addition & 0 deletions packages/next/src/server/config-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export interface ExperimentalConfig {
caseSensitiveRoutes?: boolean
appDocumentPreloading?: boolean
preloadEntriesOnStart?: boolean
/** @default true */
strictNextHead?: boolean
Comment on lines +191 to 192
Copy link
Member

@ijjk ijjk May 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this was experimental I think we can remove it, unless there's still a valid case for disabling?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timneutkens mentioned that some people may complain for SEO reasons even though extra attributes do not affect it. At least that's what happened in the past he said.

If this comes up, and people don't provide evidence that strictNextHead: true is bad, we can offer strictNextHead: false as an escape hatch. Client-side updates to next/head children would be broken but at least it would fix their imagined SEO issues.

But practically, I want to remove this soon after Next.js 15 is out stable. vercel/front is running with strictNextHead for a while by that time so it should've had sufficient soak-time.

clientRouterFilter?: boolean
clientRouterFilterRedirects?: boolean
Expand Down
5 changes: 0 additions & 5 deletions test/e2e/next-head/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ describe('next/head', () => {
pages: new FileRef(join(__dirname, 'app/pages')),
components: new FileRef(join(__dirname, 'app/components')),
},
nextConfig: {
experimental: {
strictNextHead: true,
},
},
})
})
afterAll(() => next.destroy())
Expand Down