Skip to content

docs: polyfills usage in app router #80447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Aug 6, 2025
Merged

Conversation

icyJoseph
Copy link
Contributor

@icyJoseph icyJoseph commented Jun 12, 2025

@ijjk ijjk added created-by: Next.js DevEx team PRs by the DX team. Documentation Related to Next.js' official documentation. labels Jun 12, 2025
Copy link
Member

@ztanner ztanner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're adding quite a bit of detail to how to handle polyfills in app router but the pages router approach is fairly handwavy.

Presumably some of the strategies we're talking about in app router would apply to pages router (eg loading the module in the individual component) so perhaps we can split this out into things that are truly router specific? (Which I think would just be importing it into a root layout rather than the _app component)

Comment on lines 56 to 62
```ts filename="instrumentation-client.ts" switcher
import './polyfills'
```

```js filename="instrumentation-client.js" switcher
import './polyfills'
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need switcher when the code is the same?


To include polyfills, you can import them into the [`instrumentation-client.js` file](/docs/app/api-reference/file-conventions/instrumentation-client).

For other cases, you can create a client module that loads the polyfills you need. For example if you only want to polyfill client side:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This paragraph doesn't seem right here since it comes right before the instrumentation-client code snippet

@icyJoseph icyJoseph enabled auto-merge (squash) August 6, 2025 21:06
@icyJoseph icyJoseph merged commit 6cae6d8 into canary Aug 6, 2025
75 checks passed
@icyJoseph icyJoseph deleted the docs/app-router-polyfill branch August 6, 2025 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
created-by: Next.js DevEx team PRs by the DX team. Documentation Related to Next.js' official documentation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docs: Custom Polyfills for App Router is outdated
4 participants