Next.js Discord

Discord Forum

static import and dynamic import

Unanswered
Turkish Angora posted this in #help-forum
Open in Discord
Turkish AngoraOP
Hello next.js team and guys, I hope you all are doing great. I stared learning next.js 15 2 weeks ago, then I'm practicing with simple project. i'm encoutering an issue on import statement as depicted below:

1. I'd like create some env varibles in .env.local file like
GLOBAL_S_JOBFILE = "@/mock_jobs_50_with_id.json";
2. import jobArr from process.env.GLOBAL_S_JOBFILE , this cannot be used, because this looks dynamic
3. then tried to use
jobArr=await import(process.env.GLOBAL_S_JOBFILE ) dynamic import function, still didnt work. Next prompted with an error , "this is too dynamic"

It turned out , how can i use import with ENV in a correct way? There are some global varibles that need to be shard through the whole project.:next_yellow:

thanks:heartvercel:
Danny

0 Replies