ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β π nextjs/architecture/supported-browsers β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β
Next.js supports modern browsers with zero configuration.
If you would like to target specific browsers or features, Next.js supports Browserslist configuration in your package.json file. Next.js uses the following Browserslist configuration by default:
{
"browserslist": ["chrome 111", "edge 111", "firefox 111", "safari 16.4"]
}
We inject widely used polyfills, including:
whatwg-fetch and unfetch.url package (Node.js API).object-assign, object.assign, and core-js/object/assign.If any of your dependencies include these polyfills, theyβll be eliminated automatically from the production build to avoid duplication.
In addition, to reduce bundle size, Next.js will only load these polyfills for browsers that require them. The majority of the web traffic globally will not download these polyfills.
If your own code or any external npm dependencies require features not supported by your target browsers (such as IE 11), you need to add polyfills yourself.
To include polyfills, you can import them into the instrumentation-client.js file.
import './polyfills'
In this case, you should add a top-level import for the specific polyfill you need in your Custom <App> or the individual component.
import './polyfills'
import type { AppProps } from 'next/app'
export default function MyApp({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />
}
import './polyfills'
export default function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />
}
The best approach is to isolate unsupported features to specific UI sections and conditionally load the polyfill if needed.
import { useCallback } from 'react'
export const useAnalytics = () => {
const tracker = useCallback(async (data: unknown) => {
if (!('structuredClone' in globalThis)) {
import('polyfills/structured-clone').then((mod) => {
globalThis.structuredClone = mod.default
})
}
/* Do some work that uses structured clone */
}, [])
return tracker
}
import { useCallback } from 'react'
export const useAnalytics = () => {
const tracker = useCallback(async (data) => {
if (!('structuredClone' in globalThis)) {
import('polyfills/structured-clone').then((mod) => {
globalThis.structuredClone = mod.default
})
}
/* Do some work that uses structured clone */
}, [])
return tracker
}
Next.js allows you to use the latest JavaScript features out of the box. In addition to ES6 features, Next.js also supports:
import() (ES2020)Next.js has built-in TypeScript support. Learn more here.
You can customize babel configuration. Learn more here.
β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ