Next.js Discord

Discord Forum

Relocate public directory?

Answered
Spinge Bib Sqorpnts posted this in #help-forum
Open in Discord
Is it possible to configure a directory, outside the project root, to act as the public/ directory? I have a monorepo and I want multiple projects to share the same public/ dir
Answered by joulev
i don't think it is possible. in cases like this i just use symlinks: make a public folder in the nextjs project that is a symlink to the actual shared public folder. then nextjs should still pick it up but you only have to maintain one public folder.
View full answer

7 Replies

Or rather an even better solution, allow each project to have their own public/ directory, along with shared assets
@Spinge Bib Sqorpnts Is it possible to configure a directory, outside the project root, to act as the `public/` directory? I have a monorepo and I want multiple projects to share the same `public/` dir
i don't think it is possible. in cases like this i just use symlinks: make a public folder in the nextjs project that is a symlink to the actual shared public folder. then nextjs should still pick it up but you only have to maintain one public folder.
Answer
yeah i think the name public is hardcoded in the nextjs source code already, there isn't much you can do except symlinks. the public folder is not configurable.