Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
ce3d9639
Unverified
Commit
ce3d9639
authored
Oct 08, 2025
by
Jiwon Choi
Committed by
GitHub
Oct 08, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[backport] Add deprecation warning to Runtime config (#84168) (#84650)
This PR backports #84168
parent
ec69752d
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
93 additions
and
3 deletions
+93
-3
config.js
packages/next/config.js
+12
-1
config-shared.ts
packages/next/src/server/config-shared.ts
+4
-2
config.ts
packages/next/src/server/config.ts
+13
-0
runtime-config.external.ts
packages/next/src/shared/lib/runtime-config.external.ts
+6
-0
layout.tsx
...app-dir/deprecation-warning-runtime-config/app/layout.tsx
+8
-0
page.tsx
...e/app-dir/deprecation-warning-runtime-config/app/page.tsx
+6
-0
deprecation-warning-runtime-config.test.ts
...runtime-config/deprecation-warning-runtime-config.test.ts
+16
-0
next.config.js
...app-dir/deprecation-warning-runtime-config/next.config.js
+13
-0
deprecation-warnings.test.ts
test/e2e/deprecation-warnings/deprecation-warnings.test.ts
+8
-0
next.config.js
...n-warnings/fixtures/with-deprecated-config/next.config.js
+7
-0
No files found.
packages/next/config.js
View file @
ce3d9639
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'
)
})()
packages/next/src/server/config-shared.ts
View file @
ce3d9639
...
...
@@ -1235,14 +1235,16 @@ export interface NextConfig extends Record<string, any> {
/**
* 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
}
...
...
packages/next/src/server/config.ts
View file @
ce3d9639
...
...
@@ -109,6 +109,19 @@ function checkDeprecations(
silent
)
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
)
if
(
userConfig
.
experimental
?.
dynamicIO
!==
undefined
)
{
warnOptionHasBeenDeprecated
(
userConfig
,
...
...
packages/next/src/shared/lib/runtime-config.external.ts
View file @
ce3d9639
let
runtimeConfig
:
any
/**
* @deprecated Runtime config is deprecated and will be removed in Next.js 16.
*/
export
default
()
=>
{
return
runtimeConfig
}
/**
* @deprecated Runtime config is deprecated and will be removed in Next.js 16.
*/
export
function
setConfig
(
configValue
:
any
):
void
{
runtimeConfig
=
configValue
}
test/e2e/app-dir/deprecation-warning-runtime-config/app/layout.tsx
0 → 100644
View file @
ce3d9639
import
{
ReactNode
}
from
'react'
export
default
function
Root
({
children
}:
{
children
:
ReactNode
})
{
return
(
<
html
>
<
body
>
{
children
}
</
body
>
</
html
>
)
}
test/e2e/app-dir/deprecation-warning-runtime-config/app/page.tsx
0 → 100644
View file @
ce3d9639
import
getConfig
from
'next/config'
export
default
function
Page
()
{
getConfig
()
return
<
p
>
hello world
</
p
>
}
test/e2e/app-dir/deprecation-warning-runtime-config/deprecation-warning-runtime-config.test.ts
0 → 100644
View file @
ce3d9639
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.'
)
})
})
test/e2e/app-dir/deprecation-warning-runtime-config/next.config.js
0 → 100644
View file @
ce3d9639
/**
* @type {import('next').NextConfig}
*/
const
nextConfig
=
{
publicRuntimeConfig
:
{
foo
:
'bar'
,
},
serverRuntimeConfig
:
{
foo
:
'bar'
,
},
}
module
.
exports
=
nextConfig
test/e2e/deprecation-warnings/deprecation-warnings.test.ts
View file @
ce3d9639
...
...
@@ -35,6 +35,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'
)
})
})
})
test/e2e/deprecation-warnings/fixtures/with-deprecated-config/next.config.js
View file @
ce3d9639
/** @type {import('next').NextConfig} */
module
.
exports
=
{
// Explicitly configure deprecated options
amp
:
{
...
...
@@ -6,4 +7,10 @@ module.exports = {
experimental
:
{
instrumentationHook
:
true
,
},
publicRuntimeConfig
:
{
foo
:
'bar'
,
},
serverRuntimeConfig
:
{
foo
:
'bar'
,
},
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment