Next.js Discord

Discord Forum

How to dynamically import a component with unknown name ?

Unanswered
English Angora posted this in #help-forum
Open in Discord
English AngoraOP
Dynamic Importing of an unknown component is not working in vercel deployment after I migrated from Page router to App router. Everything works fine when i build on my local system.

This is the code i used for the importing purpose.

==================================
import dynamic from "next/dynamic";

export function getDynamicComponent(location) {
return dynamic(() => import(../../websites/${location}));
}
==================================

After the migration an error started throwing only in production mode.
TypeError: L.current is null this is the log in the web console.

I will attach an image of the full log in console.

By the way the build process is completing successfully in vercel and the problem only exists when i open the page with dynamic import.

0 Replies