Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

323
Views
How to run nextjs dev server with the config from another project?

I develop a nextjs application. Inside the root folder, I've made landing/pages/ folder and I want to run dev server with those pages using next dev ./landing. The point is to create a separate app using the same codebase, configs, etc.

Dev server runs properly, but most features don't work:

  • .env is not read from the root folder (the workaround is to use cp .env ./landing && next dev ./landing). but it's an ugly way to solve it
  • assets are read from public folder inside the /landing. But I'd like to use the public folder from the root.
  • I can't use components from folders that are "above" /landing folder in the project structure. The compiler throws an error You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.

Is there any custom configuration to solve the problem? Maybe there is another way to have something like two "pages" folders in which there is the same source code, but thanks to it I could build two separate apps?

I've pushed my current code to the following repository: https://github.com/michalgrzasko/nextjs-2-pages-example

Just run dev server using yarn dev. To reproduce errors:

  • Uncomment process.env.NEXT_PUBLIC_APP_BASE_URL in landing/pages/index.tsx
  • Uncomment <Nav /> component in the same file
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

.env is not runnable files, if you will load from "somewhere" - you don't need it. You should focus on the next.config.js file. Check this, maybe will help.

Anyway, you will need:

-API from your second source(from where you like to load config)

-Load config every time once you dev build your project.

-use process.env.your_name in your classes/functions

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!