Skip to content

Commit

Permalink
docs: adjust custom polyfill suggestion (#13766)
Browse files Browse the repository at this point in the history
The current [with-polyfills](https://github.com/vercel/next.js/blob/canary/examples/with-polyfills/) example is not the suggested way to add polyfills and is known to cause issues with bundling.

The proper way to load polyfills is to include them as the first line in `pages/_app.js`, which I've updated the docs to say.
  • Loading branch information
Timer authored Jun 4, 2020
1 parent dbe5973 commit 7d9b331
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions docs/basic-features/supported-browsers-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ If any of your dependencies includes these polyfills, they’ll be eliminated au

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.

### Server-side Polyfills
### Server-Side Polyfills

In addition to `fetch()` on the client side, Next.js polyfills `fetch()` in the Node.js environment. You can use `fetch()` on your server code (such as `getStaticProps`) without using polyfills such as `isomorphic-unfetch` or `node-fetch`.

### Custom Polyfills (Advanced)
### Custom Polyfills

If your own code or any external npm dependencies require features not supported by your target browsers, you need to add polyfills yourself. In that case, you can take a look at the [with-polyfills](https://github.com/vercel/next.js/blob/canary/examples/with-polyfills/) example.
If your own code or any external npm dependencies require features not supported by your target browsers, you need to add polyfills yourself.

In this case, you should add a top-level import for the **specific polyfill** you need in your [Custom `<App>`](docs/advanced-features/custom-app.md) or the individual component.

## JavaScript Language Features

Expand Down

0 comments on commit 7d9b331

Please sign in to comment.