An Unreasonable Effort to Port Spliit to Cloudflare

February 28, 2026
Spliit logo
(on Cloudflare)

Spliit is a free and open source alternative to Splitwise. I swapped Spliit's ORM (object-relational mapping) layer from Prisma to Drizzle, just so that I could host Spliit on Cloudflare instead of Vercel. It's an unreasonable amount of work, but now my instance of Spliit runs blazing fast on the Cloudflare network. Skip to the end for a speed comparison.

Spliit-on-Cloudflare is available on GitHub.

Porting Spliit from Vercel to Cloudflare

The official Spliit is very easy to deploy on the free tier of Vercel (a cloud provider), almost in a single click. This type of self-hosted instance is completely functonional, and a good replacement for Splitwise or Tricount.

The problem is that Spliit is (painfully) slow when hosted on the Vercel free tier. While the web pages load within a reasonable time, the root cause of the slowness seemed to be the Postgres database used to dynamically load data.

Rather than pay for more resources at Vercel, it would be great if I could just deploy Spliit on Cloudflare instead. Cloudflare's Workers platform has a plenty generous free tier for small, personal projects, and, knowing Cloudflare's network, is designed for speed.

Swapping Prisma for Drizzle

Cloudflare does not support traditional databases such as Postgres, opting instead for Cloudflare's own "D1" database that supports SQLite-like interactions. @bruce965 on GitHub had already investigated how to port Spliit from Postgres to SQLite, which is not that much work since the Prisma ORM framework used by Spliit already supports multiple database backends (such as SQLite).

Here's where it gets tricky. The Cloudflare free tier mandates that a bundled web application, without assets, is at most 3MB gzipped. When I checked for Spliit + Prisma, bundle size came in around 3.7MB gzipped with most of it consumed by NextJS (& dependencies), and crucially, a .wasm file used solely by Prisma.

A GitHub Copilot Success? Not Quite

This is the part where a bit of effort became an unreasonable amount of effort. Since I have access to GitHub Copilot pro (using OpenAI GPT-5.3-Codex), I thought to ask it to swap Prisma for Drizzle, a more lightweight ORM framework that would not require a .wasm backend.

The result was surprising and frustrating.

  • The surprising part: I was very surprised to see that, in an afternoon of work and some back and forth trial and error, Github Copilot swapped out around ~1000 lines of code responsible for preparing SQL statements and querying the database. Surprisingly, it managed to get a proof-of-concept up and running.
  • The frustrating part: The code was quite bad, approximately "third year bachelor student"-level, and it required manual review and fixing throughout. The frustrating part was that I now had a proof of concept to work with, which is very easy to sink more time into.

I manually rewrote the approximately ~1000 lines of code to simplify it and to fix mistakes.

An AI's Bad Solution to a Problem

At one point during development, I tried to configure the project to use SQLite locally, and Cloudflare's D1 in production. In principle they both speak SQLite SQL.

The code written by Github Copilot worked in local development, but on Cloudflare, SQL statements would fail due to a syntax error on BEGIN TRANSACTION;. I asked Copilot to fix the problem, and it came up with the following solution to wrap all database queries.

async function transactionWithFallback<T>(db, callback: (db) => Promise<T>): Promise<T> {
  try {
    return db.transaction(callback(db));
  } catch (e) {
    if (e.message.contains("BEGIN TRANSACTION;")) {
      return callback(db);
    }
  }
}

In words: try in a transaction, and if the error message includes the magic words, yeet the code again without a transaction ¯\(ツ)/¯.

As it turns out, Cloudflare's D1 database does not support transactions in this way, and instead requires statements to be batched together. Copilot didn't know that. It fixed the issue, but in the same way a student might when a deadline is near.

Bunde Size Revisited

After the unreasonable effort, this is the result on the Bundle size:

Total Upload: 10214.37 KiB / gzip: 2961.55 KiB
Worker Startup Time: 30 ms
Your Worker has access to the following bindings:
Binding              Resource         
env.DB (DB)          D1 Database      
env.ASSETS           Assets   

Success! Tens of kilobytes to spare.

How Fast is Spliit on Cloudflare? It's Fast

See the difference between Spliit 1.19.1 hosted on Vercel (free tier) vs. Cloudflare (free tier).

  • Spliit on Vercel load time: 5.1 s
  • Spliit on Cloudflare load time: 0.6 s

Run Spliit on Cloudflare Yourself

Users who want a better free, self-hosted user experience can run Spliit on Cloudflare.

The code is available on GitHub, with instructions to deploy on Cloudflare.

RSS
https://sxv.be/blog/feed.xml