With Next.js, it is possible to load modules based on conditions with the help of dynamic import.

Typically, it is impossible to import modules based on the condition. Whenever a page loads, all the imported modules on that particular page also get loaded.

const allowImport = true;
if (allowImport) {
  import DynamicComponent from "../components/hello";
export default function Home() {
  return (
      <DynamicComponent />

#javascript #software-development #programming #next #react

How to Perform Dynamic Import with Next.js
2.30 GEEK