11// XXX: Blocked by https://github.com/vercel/next.js/pull/58129
22// import { headers } from 'next/headers';
3- import Script , { ScriptProps } from 'next/script' ;
3+ import Script , { type ScriptProps } from 'next/script' ;
44import { type FC } from 'react' ;
55
66import { type NonceConfig } from '../typings/nonce' ;
@@ -10,8 +10,8 @@ import { PUBLIC_ENV_KEY } from './constants';
1010type EnvScriptProps = {
1111 env : ProcessEnv ;
1212 nonce ?: string | NonceConfig ;
13- withNextScriptComponent ?: boolean ;
14- nextScriptComponentProps ?: ScriptProps ;
13+ disableNextScript ?: boolean ;
14+ nextScriptProps ?: ScriptProps ;
1515} ;
1616
1717/**
@@ -28,8 +28,8 @@ type EnvScriptProps = {
2828export const EnvScript : FC < EnvScriptProps > = ( {
2929 env,
3030 nonce,
31- withNextScriptComponent = true ,
32- nextScriptComponentProps = { strategy : 'beforeInteractive' } ,
31+ disableNextScript = false ,
32+ nextScriptProps = { strategy : 'beforeInteractive' } ,
3333} ) => {
3434 let nonceString : string | undefined ;
3535
@@ -43,23 +43,23 @@ export const EnvScript: FC<EnvScriptProps> = ({
4343 nonceString = nonce ;
4444 }
4545
46- const html = {
46+ const innerHTML = {
4747 __html : `window['${ PUBLIC_ENV_KEY } '] = ${ JSON . stringify ( env ) } ` ,
4848 } ;
4949
5050 // You can opt to use a regular "<script>" tag instead of Next.js' Script Component.
5151 // Note: When using Sentry, sentry.client.config.ts might run after the Next.js <Script> component, even when the strategy is "beforeInteractive"
5252 // This results in the runtime environments being undefined and the Sentry client config initialized without the correct configuration.
53- if ( ! withNextScriptComponent ) {
54- return < script nonce = { nonceString } dangerouslySetInnerHTML = { html } /> ;
53+ if ( disableNextScript ) {
54+ return < script nonce = { nonceString } dangerouslySetInnerHTML = { innerHTML } /> ;
5555 }
5656
5757 // Use Next.js Script Component by default
5858 return (
5959 < Script
60- { ...nextScriptComponentProps }
60+ { ...nextScriptProps }
6161 nonce = { nonceString }
62- dangerouslySetInnerHTML = { html }
62+ dangerouslySetInnerHTML = { innerHTML }
6363 />
6464 ) ;
6565} ;
0 commit comments