I'm wondering about the difference between dynamic import
(next.js feature) and await import
.
I couldn't find an explanation about the difference online.
I know that you can use dynamic import
only to import React Components
and not libraries.
But why should I use dynamic import
and not just await import
?
thanks
As they explain here https://nextjs.org/docs/advanced-features/dynamic-import, you should use
next/dynamic
when you import dynamic React components to be sure that NextJS is able to match webpack bundles to a specific dynamic call, and preload the component before rendering it.So the answer to you question is yes, you should use Nextjs
dynamic
import, and notawait import
(btw,await import
is just a way to loadES2020 dynamic imports
)