Vercel

For the easiest deployment, you can use Vercel. You may need to create a database using Vercel Postgres for your app. Here's how you can deploy your app:

  1. Add a new project and import from your GitHub repository.
  2. Set up the environment variables in the project settings.
  3. Then, deploy your app. Vercel will automatically build and deploy your app every time you push it to your repository. Done.

Self-Hosting

An easy way to self-host is to use PM2 as the process manager and reverse proxy with Nginx. The recommended machine specifications if you want to sleep well are:

  • 2 vCPU
  • 2 GiB RAM
  • 10 GiB SSD
  • Ubuntu 24.04 AMD64

If you're using AWS, you can create a t3.small EC2 instance. Follow these steps to deploy your app:

  1. Initialize the necessary packages by running the following script:

    bash

    function init() { echo "Initializing the necessary packages..." && \ sudo apt-get update -y && \ sudo apt-get upgrade -y && \ sudo apt-get install build-essential -y && \ sudo apt-get install unzip -y && \ sudo apt-get install redis -y && \ sudo apt-get install nginx -y && \ sudo apt-get install certbot python3-certbot-nginx -y && \ echo "Installing Node.js..." && \ sudo apt-get install nodejs -y && \ sudo apt-get install npm -y && \ sudo npm install -g n && \ sudo n lts && \ echo "Installing PostgreSQL 16..." && \ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' && \ curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg && \ sudo apt-get update -y && \ sudo apt install postgresql-16 postgresql-contrib-16 -y && \ sudo systemctl start postgresql && \ sudo systemctl enable postgresql && \ echo "Installing Bun..." && \ curl -fsSL https://bun.sh/install | bash } bash -c "$(declare -f init); init" && source ~/.bashrc && bun add -g pm2
  2. Clone the repository, install the dependencies, and set up your project (e.g., database, environment variables, etc.).

  3. Build the app & start the app with PM2:

    bash

    bun run build && \ pm2 start "bun run start --port 3000" --name myapp
  4. Set up Nginx

    Create a file named /etc/nginx/sites-available/app.conf with the following content: (replace example.com with your domain)

    nginx

    server { server_name example.com; client_max_body_size 10M; location / { proxy_pass http://127.0.0.1:3000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_buffering off; } }

    Create a symbolic link to the sites-enabled directory:

    bash

    sudo ln -s /etc/nginx/sites-available/app.conf /etc/nginx/sites-enabled/

    Then, restart Nginx:

    bash

    sudo service nginx restart
  5. Update your DNS records to point to your server's IP address. Then, set up SSL with Certbot:

    bash

    sudo certbot --nginx -d example.com

    Fill in the required information and you're done! 🎉