Capítulo 450 de 456
Next.js supports modern browsers with zero configuration, injects only-when-needed polyfills, and allows targeting custom browsers via Browserslist.
package.json; defaults to ["chrome 111", "edge 111", "firefox 111", "safari 16.4"].fetch(), URL, Object.assign() — only loaded for browsers that need them, and deduped if a dependency already includes them.instrumentation-client.js/.ts; Pages Router via a top-level import in Custom <App> (pages/_app.tsx) or the specific component.import() the polyfill only when missing (e.g. structuredClone).import(), Optional Chaining, Nullish Coalescing, Class Fields/Static Properties, and more.import './polyfills'
export const useAnalytics = () => {
const tracker = useCallback(async (data: unknown) => {
if (!('structuredClone' in globalThis)) {
const mod = await import('polyfills/structured-clone')
globalThis.structuredClone = mod.default
}
}, [])
return tracker
}