
How I use RPC Supabase in my following projects. By MINSEO KIM | April 2025

I used Supabase with Next.js For my past and current personal projects because of the ease with which it fits into a frontal setting – no need to maintain a separate back -end.
However, as my projects have become more complex, I started to reach limits with the JavaScript Supabase client.
For example, it does not support SQL key features as TRANSACTIONS
Or GROUP BY
which has become essential for my data processing logic.
This is where I discovered Remote procedure calls (RPC). Using supabase.rpc()
I was able to unlock all the power of the postgre functions for my use cases.
In Supabase, RPCs allow you to run PostgreSql functions directly from the customer, like calling an API.
Instead of chaining a series of .select()
,, .insert()
Or .update()
Calls in JavaScript, you can define a single postgre function and call it by using:
supabase.rpc('function_name', { params })
All the logic is executed Inside the databaseThis means that it is faster, safer and often cleaner than manipulating it on the customer.
1. Management of complex commercial logic
Sometimes your application must run a series of steps that extend over several tables.
For example, place an order may involve:
- Calculation of the total cost (taking into account good, taxes, shipments)
- Stock verification
inventory
- Deduce articles from inventory
- Inserted in the
orders
painting - Create a recording in
invoices
- Bonbotage repurchase
- Insert
event_logs
Do this in JavaScript with several supabase.from(...).insert()
And .update()
Calls become disorderly – and subject to errors.
With an RPC, you wrap everything in a function on the database, which makes it easier to debug and maintain.