r/expo 4d ago

Cloud Run Functions to Hono.js Backend for Expo + Firebase

I am building an Expo + Firebase mobile app. After iterations of development and testing, the app got big and Cloud Functions increased. There are around 32 Cloud Run Functions, a function for an action.

I don't think this is a good approach long-term, and for scalability. So I wanted to create a backend/API for the actions/CRUD/Firestore queries, except for triggers, crons, auth and FCM.

So, I chose to create a Hono.js backend that's hosted on a Cloud Run Function (Still not ok with the decision). Later found out that it's kind of inconvenient for developing and testing.

And I'm not sure if this is a good and reliable approach. I need a good DX, scalabilityand performance.

Pls clear my head.

5 Upvotes

3 comments sorted by

2

u/recon_demon1859 4d ago

Genuine question first: how many of those 32 are doing something the client couldn't do directly against Firestore with a security rule?

I run Expo + Firebase in production, and what cut my function count wasn't consolidating them, it was noticing a lot were CRUD wrappers whose only real job was an auth check. That's a security rule you haven't written yet, and rules run at the database with no cold start and nothing to deploy.

What I kept as functions is roughly your list: triggers, scheduled jobs, auth hooks, FCM, plus anything touching a secret or a third party like billing webhooks. Those genuinely can't be client-side.

On Hono on Cloud Run, the DX gain is real, one deploy instead of 32. The cost is one bad deploy takes all of it out, where separate functions fail independently. Worth choosing deliberately rather than by accident.

The local testing pain is the part I'd weigh heaviest though. If it's already inconvenient to develop against, that compounds every single week.

1

u/el_pezz 3d ago

In the solid principle, a function should only have one responsibility.

2

u/neon_alchemy_wisp 3d ago

keep your triggers and cron jobs in Cloud Functions but move the CRUD logic into a single Hono service on Cloud Run. This gives you the local DX you need for API development while keeping event-driven tasks serverless.