diff --git a/packages/next/build/webpack-config.ts b/packages/next/build/webpack-config.ts
index bf049ee6eac1b..fd6ec5cd00d00 100644
--- a/packages/next/build/webpack-config.ts
+++ b/packages/next/build/webpack-config.ts
@@ -736,6 +736,9 @@ export default async function getBaseWebpackConfig(
'process.env.__NEXT_PRERENDER_INDICATOR': JSON.stringify(
config.devIndicators.autoPrerender
),
+ 'process.env.__NEXT_STRICT_MODE': JSON.stringify(
+ config.reactStrictMode
+ ),
...(isServer
? {
// Fix bad-actors in the npm ecosystem (e.g. `node-formidable`)
diff --git a/packages/next/client/index.js b/packages/next/client/index.js
index 2eed1010881e8..02118913c1c4e 100644
--- a/packages/next/client/index.js
+++ b/packages/next/client/index.js
@@ -372,11 +372,19 @@ async function doRender ({ App, Component, props, err }) {
appProps
})
- // We catch runtime errors using componentDidCatch which will trigger renderError
- renderReactElement(
+ const elem = (
- ,
+
+ )
+
+ // We catch runtime errors using componentDidCatch which will trigger renderError
+ renderReactElement(
+ process.env.__NEXT_STRICT_MODE ? (
+ {elem}
+ ) : (
+ elem
+ ),
appElement
)
diff --git a/packages/next/next-server/server/config.ts b/packages/next/next-server/server/config.ts
index 60f3ac43758eb..712eca701718a 100644
--- a/packages/next/next-server/server/config.ts
+++ b/packages/next/next-server/server/config.ts
@@ -53,6 +53,7 @@ const defaultConfig: { [key: string]: any } = {
},
serverRuntimeConfig: {},
publicRuntimeConfig: {},
+ reactStrictMode: false,
}
const experimentalWarning = execOnce(() => {