Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the public directory of a next js application

I have a monorepo with the following architecture:

apps/
  web/
    - next.config.js
    - pages/
public/

My next js application is in the apps/web/ folder. How do I change the next.config.js file so that it knows to serve public assets from the public folder at the root of my monorepo and not in the apps/web/ folder?

like image 264
Jimmy Avatar asked Feb 03 '26 17:02

Jimmy


1 Answers

According to the next.js docs, you cannot

Note: Be sure the directory is named public. The name cannot be changed and is the only directory used to serve static assets.

Note: Only assets that are in the public directory at build time will be served by Next.js. Files added at runtime won't be available. We recommend using a third party service like AWS S3 for persistent file storage.

like image 118
Yilmaz Avatar answered Feb 05 '26 05:02

Yilmaz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!