How to access files uploaded to the public folder in Next.js?

From Next.js documentation:

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.

You’ll have to persist the uploaded files somewhere else if you want to have access to them in the app at run time.


Alternatively, you could setup your own custom server in Next.js, which would give you more control to serve static files/assets.

You can also achieve something similar using API routes instead. See Next.js serving static files that are not included in the build or source code for details.

Leave a Comment