Custom polyfills #20992
-
In the NextJS docs on polyfills, it says to add custom polyfills via Specifically, I'm looking for a way to load custom polyfills only for browsers that need them. For instance, a ResizeObserver or IntersectionObserver polyfill. P.S. The example in the examples folder says that that's not the recommended way of loading polyfills. It just references the docs for custom polyfills. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 26 replies
-
Good catch — this isn't very clear right now. You should add a top-level import for the specific polyfill you need in your Custom import 'resize-observer-polyfill'
function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />
}
export default MyApp I will update the example 👍 |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm having this issue but with Next 13.x and using the Thanks! |
Beta Was this translation helpful? Give feedback.
-
RaenonX-PokemonSleep/pokemon-sleep-ci@d4ce3c1 Using next v14. Tried to add custom polyfill like what was shown in this thread in the commit above, but it doesn't seem like it's getting polyfilled. How do I check if it's really getting polyfilled? Edit: Solved. Need these changes and all good. RaenonX-PokemonSleep/pokemon-sleep-ci@b9fb523 |
Beta Was this translation helpful? Give feedback.
-
Any docs for importing custom webpack polyfills in next js 14?? I am trying to solve the issue for node:buffer error |
Beta Was this translation helpful? Give feedback.
Good catch — this isn't very clear right now. You should add a top-level import for the specific polyfill you need in your Custom
<App>
or the individual component. Example:I will update the example 👍