Next.js Discord

Discord Forum

Relocate public directory?

Answered
Spinge Bib Sqorpnts posted this in #help-forum
Open in Discord
Avatar
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

Avatar
Or rather an even better solution, allow each project to have their own public/ directory, along with shared assets
Avatar
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
Avatar
Unfortunate :/
Thought of symlinks as last resort, because I'm worried it'll screw up all my paths
Thanks for the help :)
Avatar
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.
Avatar
imo it sounds like a good feature request, I might open an issue later