How to avoid going broke on Vercel

How to Avoid Going Broke on Vercel A Practical Guide

Vercel is an amazing platform for deploying static websites and serverless functions. However, if you’re not careful, your costs can quickly spiral out of control. In this blog post, we’ll discuss some tips to help you avoid going broke on Vercel.

1. Avoid putting large files in the public directory

Vercel charges for bandwidth used for files in the public directory. This means that if you have large files, such as images or videos, you’ll be charged for every time they’re downloaded.

To avoid this, you can use a service like Uploadthing or S3 to store and serve your large files. This will allow you to control the bandwidth costs and only pay for the data that is actually downloaded.

2. Be mindful of image optimization

Vercel offers image optimization, but it’s not free for large numbers of images. If you have a large number of images, you may want to consider using a cheaper image optimization service.

You can also use the next/image component to optimize images. However, be careful to restrict the paths that can be optimized, as this can help to avoid accidentally optimizing images that are already optimized.

3. Optimize database queries

Vercel uses a Postgres database by default. If you’re not careful, your database queries can become expensive.

To avoid this, you can take the following steps:

  • Avoid making unnecessary database queries.
  • Use caching to reduce the number of database queries.
  • Use relations in Prisma to fetch multiple related records in a single query.

4. Use server-side rendering (SSR) for static pages

Server-side rendering (SSR) can help to improve the performance of your website and reduce costs. When you use SSR, the server renders the HTML for your pages before sending it to the browser. This can help to reduce the amount of JavaScript that needs to be downloaded, which can improve the load time of your website.

5. Use a cheaper analytics service

Vercel offers its own analytics service, but it can be expensive. If you’re on a tight budget, you may want to consider using a cheaper analytics service like PostHog.

6. Use Vercel’s spend management feature

Vercel offers a spend management feature that allows you to set a spending limit. This can help to avoid unexpected costs.


Posted

in

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *