Skip to content

Commit 3552445

Browse files
authored
Docs/polyfills fix pages only (#82462)
Follow up for: #74730
1 parent 4eb46d8 commit 3552445

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

docs/03-architecture/supported-browsers.mdx

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,37 @@ In addition, to reduce bundle size, Next.js will only load these polyfills for b
4343

4444
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.
4545

46-
<PagesOnly>
47-
In this case, you should add a top-level import for the **specific polyfill** you need in your [Custom `<App>`](/docs/pages/building-your-application/routing/custom-app) or the individual component.
48-
</PagesOnly>
46+
#### In App Router
4947

50-
<AppOnly>
51-
5248
To include polyfills, you can import them into the [`instrumentation-client.js` file](/docs/app/api-reference/file-conventions/instrumentation-client).
5349

5450
```ts filename="instrumentation-client.ts"
5551
import './polyfills'
5652
```
5753

58-
</AppOnly>
54+
#### In Pages Router
55+
56+
In this case, you should add a top-level import for the **specific polyfill** you need in your [Custom `<App>`](/docs/pages/building-your-application/routing/custom-app) or the individual component.
57+
58+
```tsx filename="pages/_app.tsx" switcher
59+
import './polyfills'
60+
61+
import type { AppProps } from 'next/app'
62+
63+
export default function MyApp({ Component, pageProps }: AppProps) {
64+
return <Component {...pageProps} />
65+
}
66+
```
67+
68+
```jsx filename="pages/_app.jsx" switcher
69+
import './polyfills'
70+
71+
export default function MyApp({ Component, pageProps }) {
72+
return <Component {...pageProps} />
73+
}
74+
```
75+
76+
#### Conditionally loading polyfills
5977

6078
The best approach is to isolate unsupported features to specific UI sections and conditionally load the polyfill if needed.
6179

0 commit comments

Comments
 (0)