You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: Adapter for firebase callable functions #6388
An adapter such that web clients can call a type safe client API routed to firebase callable functions (a single function instance) that is then implemented in the backend in the usual way but wrapping the callable functions specification (e.g. use firebase's context for context etc.)
Describe the solution you'd like to see
Actually, I don't expect a solution from the core team - I'm offering to write it myself
Describe alternate solutions
Currently rolling my own RPC framework around zod - but why maintain that wheel when trpc exists
Additional information
Per above, I'm up for doing the implementation if noone else has done anything. Purpose of me filing this ticket is to ask what consideration has been given to this before and whether I'm likely to run into any gotchas if I go down this road or it should be as simple as another adapter. Also, pointing me to the most relevant existing adapter would be helpful to me.
👨👧👦 Contributing
🙋♂️ Yes, I'd be down to file a PR implementing this feature!
I had a start but I think I have to suspend effort for now as the way firebase does monorepo doesn't cleanly fit with trpc. (The client and server have their own package.json and tsconfig.json. Server must target cjs, client on ESM. It's a bit too much to untangle at this time).
In case anyone else tries, what I did succeed in doing is setting up the backend to be based on trpc and handle as callable functions. My existing front end code was able to call it just fine. Here's a code snippet
exportconsttrpcFunction=onCall({/* your options here */},async(req)=>{constdata=req.dataconstfn: string=data.function// by conventionconstprocedures=appRouter._def.proceduresasunknownasRouterRecordconstcb=procedures[fn]asAnyProcedureif(!cb)thrownewfunctions.https.HttpsError('invalid-argument',`Function name "${fn}" must be a valid string in data.function`)// TODO: catch trpc errors and rethrow as HttpsErrorreturnawaitcb({path: fn,getRawInput: async()=>req,ctx: req,type: cb._def.type,// actually must be POST/mutation by callable conventionsignal: undefined,})})
I'm making decent progress - my firebase callables backend is now entirely on trpc which has the added bonus that all the tests get the typesafe proxies to use and my procedures are now portable if I need to switch away from callable functions. It will be a slow process to get the front end adapters working too to bring it all together.
If anyone else has interest in the effort, ping me and I'll share everything useful.
Activity
KATT commentedon Jan 13, 2025
glorat commentedon Jan 19, 2025
I had a start but I think I have to suspend effort for now as the way firebase does monorepo doesn't cleanly fit with trpc. (The client and server have their own package.json and tsconfig.json. Server must target cjs, client on ESM. It's a bit too much to untangle at this time).
In case anyone else tries, what I did succeed in doing is setting up the backend to be based on trpc and handle as callable functions. My existing front end code was able to call it just fine. Here's a code snippet
glorat commentedon Feb 8, 2025
I'm making decent progress - my firebase callables backend is now entirely on trpc which has the added bonus that all the tests get the typesafe proxies to use and my procedures are now portable if I need to switch away from callable functions. It will be a slow process to get the front end adapters working too to bring it all together.
If anyone else has interest in the effort, ping me and I'll share everything useful.
saenzramiro commentedon Sep 9, 2025
Any progress/news on this? It will be great to have this.
KATT commentedon Nov 2, 2026
🤖 v12 has a Firebase callable recipe (experimental): https://v12.trpc.io/v12/docs/adapters/firebase. v12 isn't released yet and there's no ETA.