Supabase edge functions REST API

Is there any benefit in creating seperate edge functions when I'm using them as backend for my app that is only used by client? Or maybe I can just create rest edge function and create routing there using hono and make all my operations in single function that will work like rest API?
5 Replies
ihm40
ihm402w ago
The first thing that i would say is it depends on what your application is doing. Here are some useful guides on supabase limits https://supabase.com/docs/guides/functions/limits. Not knowing more context my suggestion would be to separate edge functions out to have different responsibilities but it doesn't have to be as seperated as standard http where DELETE PUT PATCH GET etc might each have their own function. Your frontend might create an item and all the ways to interact with that item might belong inside of an edge function item-manager Though ultimately as long as you consider the limitations of edge functions you can use them as you wish
Floppy Disk
Floppy DiskOP2w ago
Great, thanks But one more question. I haven't really been researching that and I'm not in the home right now so I can't test it but is it possible to manage my edge functions directly within my react application? Not inside mono repo It would save me some hustle from copy pasting types etc
ihm40
ihm402w ago
edge functions would have to live within a supabase/functions folder and they are also manged by the config.toml so there is no way to get around that what are you copy/pasting?
Floppy Disk
Floppy DiskOP2w ago
I was thinking about that item-manager you mentioned, I guess if I would want to make couple actions for it as a single function I would have to create couple different types for it and they would have to be accessible from edge functions and client as well e.g
type a = {
action: 'a',
context: {
a: number
}
}
type b = ...
type a = {
action: 'a',
context: {
a: number
}
}
type b = ...
so I know what body is like on both ends
ihm40
ihm402w ago
Right you mean the types that get passed in from the frontend and received in the edge function... I don't have any workaround for that i'm afraid. I've most likley just always copied over

Did you find this page helpful?