Next.js Discord

Discord Forum

storing images in /public

Answered
Yellowhead catfish posted this in #help-forum
Open in Discord
Yellowhead catfishOP
I have more of a question towards vercel and nextjs, I am using the free tier, is it bad to have 5MB of images inside of my public folder? Should I move it to something like uploadthing or is it fine for it to be there?
Answered by B33fb0n3
of course you can leave it there. However it will drain your limits pretty fast. Just upload the files to an s3 or r2 or anything like that and use a cdn to serve them. Example for CDNs are r2 as well, bunnycdn, cloudfront, ...
View full answer

12 Replies

@Yellowhead catfish I have more of a question towards vercel and nextjs, I am using the free tier, is it bad to have 5MB of images inside of my public folder? Should I move it to something like uploadthing or is it fine for it to be there?
of course you can leave it there. However it will drain your limits pretty fast. Just upload the files to an s3 or r2 or anything like that and use a cdn to serve them. Example for CDNs are r2 as well, bunnycdn, cloudfront, ...
Answer
@Yellowhead catfish solved?
well i must say files added to the public folder after build are not served, so storing files there will do you no good, you cannot access them. so no, don't store files there.
@joulev well i must say files added to the public folder after build are not served, so storing files there will do you no good, you cannot access them. so no, don't store files there.
you can access them by entering the relative url to the file.
<Image src='/someImage.png' />

This would relate to "/public/someImage.png". Or am I missing something rn?
oh right i just re-read the question again and OP didn't mention anything on saving them during runtime. i misunderstood the question, apologies
@B33fb0n3 <@1022842005920940063> solved?
Yellowhead catfishOP
yes sorry i forgot to mark it :D
perfect, happy to help!
Cape lion
The best way to reduce the size of images is to convert png/jpg to webp format
@Cape lion The best way to reduce the size of images is to convert png/jpg to webp format
Yellowhead catfishOP
already doing this fyi, but i have many images that are a total of 5MB, my website has many images of my dog :D