ddedic / nextjs_vps

NextJS VPS Example

Home Page:https://vps.ashleyrudland.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Do we need Vercel? Can we just run our NextJS apps on a VM? Maybe all our apps on one machine?

I love NextJS, but I don't like Vercels pricing. It seems nuts to me and it seems many other people do too. So I spent a few hours playing with this and Digital Ocean Hetzner Cloud (€3.30/mo 🀣) to see what was possible.

All thanks goes to kamal and @ImSh4yy, I built this using his post πŸ™

What's the objective here?

Figure out if we can have all the requirements of most indie hacker apps on a little VM instead of Vercel?

Here's the list of to dos:

  • Can we run NextJS on VPS easily? βœ…
  • Is the latency acceptable? βœ… 35ms, roughly same as Vercel
  • Can we auto deploy? βœ… see deploy-on-main.yml
  • Can we persist data on this machine when using Docker?
  • How much traffic can this machine handle concurrently? Around 750 HTTP requests/sec on Hetzner €3.29/mo VPS, before it starts to slow down, see this load test report
  • What's the writes per second using SQL Lite? βœ… 14,000/sec on Hetzner €3.29/mo VPS
  • What's the uptime of this? βœ… so far 100%
  • NextJS Feature: Image Optimization? βœ… works!
  • NextJS Feature: Can we use Server Actions? βœ… SQLite write test runs on Server Actions. See actions
  • NextJS Feature: API routes? βœ… see /api/vm/
  • NextJS Feature: Can we use the NextJS Caching? Custom Cache?
  • Can/how we run multiple apps on the same machine? Switch app based on domain name?

What's not the objective?

  • Infinite scale - do indie hackers really need this?
  • Complex architecture

How does this auto deploy?

Basically GitHub actions run on each commit to main, builds image using Docker, uploads then Kamal connects to machine via SSH (with passphrase), then reboots app with new code.

About

NextJS VPS Example

https://vps.ashleyrudland.com


Languages

Language:TypeScript 83.1%Language:JavaScript 7.8%Language:CSS 5.9%Language:Dockerfile 3.2%