Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion packages/next/config.js
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
module.exports = require('./dist/shared/lib/runtime-config.external')
let hasWarned = false

module.exports = (() => {
if (!hasWarned) {
console.warn(
// ANSI code aligns with Next.js warning style from picocolors.
' \x1b[33m\x1b[1m⚠\x1b[22m\x1b[39m Runtime config is deprecated and will be removed in Next.js 16. Please remove the usage of "next/config" from your project.'
)
hasWarned = true
}
return require('./dist/shared/lib/runtime-config.external')
})()
6 changes: 4 additions & 2 deletions packages/next/src/server/config-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1118,14 +1118,16 @@ export interface NextConfig {
/**
* Add public (in browser) runtime configuration to your app
*
* @see [Runtime configuration](https://nextjs.org/docs/pages/api-reference/config/next-config-js/runtime-configuration
* @see [Runtime configuration](https://nextjs.org/docs/pages/api-reference/config/next-config-js/runtime-configuration)
* @deprecated Runtime config is deprecated and will be removed in Next.js 16.
*/
publicRuntimeConfig?: { [key: string]: any }

/**
* Add server runtime configuration to your app
*
* @see [Runtime configuration](https://nextjs.org/docs/pages/api-reference/config/next-config-js/runtime-configuration
* @see [Runtime configuration](https://nextjs.org/docs/pages/api-reference/config/next-config-js/runtime-configuration)
* @deprecated Runtime config is deprecated and will be removed in Next.js 16.
*/
serverRuntimeConfig?: { [key: string]: any }

Expand Down
13 changes: 13 additions & 0 deletions packages/next/src/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,19 @@ function checkDeprecations(
silent: boolean,
dir: string
) {
warnOptionHasBeenDeprecated(
userConfig,
'publicRuntimeConfig',
`Runtime config is deprecated and the \`publicRuntimeConfig\` configuration option will be removed in Next.js 16.`,
silent
)
warnOptionHasBeenDeprecated(
userConfig,
'serverRuntimeConfig',
`Runtime config is deprecated and the \`serverRuntimeConfig\` configuration option will be removed in Next.js 16.`,
silent
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we have any tests ensuring these are logged as expected?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

For deprecation warnings no, can follow up

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oh we do have test/e2e/deprecation-warnings/deprecation-warnings.test.ts

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added tests


if (userConfig.experimental?.dynamicIO !== undefined) {
warnOptionHasBeenDeprecated(
userConfig,
Expand Down
6 changes: 6 additions & 0 deletions packages/next/src/shared/lib/runtime-config.external.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
let runtimeConfig: any

/**
* @deprecated Runtime config is deprecated and will be removed in Next.js 16.
*/
export default () => {
return runtimeConfig
}
Comment on lines +3 to 8
Copy link
Copy Markdown
Member

@eps1lon eps1lon Sep 25, 2025

Choose a reason for hiding this comment

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

Can we do a runtime warning here as well?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We have internals that call this resulting warning regardless of whether the users set the value on the config. 🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We can do

if (!process.env.__NEXT_TEST_MODE) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Where do we export these methods? Can the publicly available function just wrap this one with a runtime warning? There we should set the @deprecated instead of on the internal one that we want to continue using anyway.

Copy link
Copy Markdown
Member Author

@devjiwonchoi devjiwonchoi Sep 25, 2025

Choose a reason for hiding this comment

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

We can modify from here

import getConfig from './dist/shared/lib/runtime-config.external'
export * from './dist/shared/lib/runtime-config.external'
export default getConfig

Copy link
Copy Markdown
Member Author

@devjiwonchoi devjiwonchoi Oct 8, 2025

Choose a reason for hiding this comment

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

There we should set the @deprecated instead of on the internal one that we want to continue using anyway.

We're not going to use it when we remove; the internal usages are setConfig for the user to use when getConfig.


/**
* @deprecated Runtime config is deprecated and will be removed in Next.js 16.
*/
export function setConfig(configValue: any): void {
runtimeConfig = configValue
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ReactNode } from 'react'
export default function Root({ children }: { children: ReactNode }) {
return (
<html>
<body>{children}</body>
</html>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import getConfig from 'next/config'

export default function Page() {
getConfig()
return <p>hello world</p>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { nextTestSetup } from 'e2e-utils'

describe('deprecation-warning-runtime-config', () => {
const { next } = nextTestSetup({
files: __dirname,
})

it('should warn when imported "next/config" module', async () => {
// Navigate to "/" for dev server to execute the code
await next.browser('/')

expect(next.cliOutput).toContain(
'Runtime config is deprecated and will be removed in Next.js 16. Please remove the usage of "next/config" from your project.'
)
})
})
13 changes: 13 additions & 0 deletions test/e2e/app-dir/deprecation-warning-runtime-config/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
publicRuntimeConfig: {
foo: 'bar',
},
serverRuntimeConfig: {
foo: 'bar',
},
}

module.exports = nextConfig
8 changes: 8 additions & 0 deletions test/e2e/deprecation-warnings/deprecation-warnings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ describe('deprecation-warnings', () => {
// Should warn about experimental.instrumentationHook
expect(logs).toContain('experimental.instrumentationHook')
expect(logs).toContain('no longer needed')

// Should warn about publicRuntimeConfig
expect(logs).toContain('publicRuntimeConfig')
expect(logs).toContain('will be removed in Next.js 16')

// Should warn about serverRuntimeConfig
expect(logs).toContain('serverRuntimeConfig')
expect(logs).toContain('will be removed in Next.js 16')
})
})
})
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
/** @type {import('next').NextConfig} */
module.exports = {
// Explicitly configure deprecated options
experimental: {
instrumentationHook: true,
},
publicRuntimeConfig: {
foo: 'bar',
},
serverRuntimeConfig: {
foo: 'bar',
},
}
Loading