borisfyi
borisfyi•12h ago

How not to expose functions to the client but still be able to call them server side somehow?

Hello 👋 Following: https://discord.com/channels/1019350475847499849/1019350478817079338/1440040205036949606 I'm using Next.js App Router and in a server action I need to call a convex query. I'm aware that I can protect queries with auth, but when I discovered internal function I figured not exposing the function to the client at all would be even better than protecting it. Problem is: we can't call convex internal functions outside of some specific use cases. Actions are one of them. But in order to be able to call actions from my Next.js server action, this action needs to be public (ie: exposed to the client). I can see why it might be useful sometimes, but in my case the action would just wrap the internal function... effectively making that function public. So: How not to expose functions to the client but still be able to call them server side somehow? Thanks in advance for your help, Boris
3 Replies
Patolord
Patolord•10h ago
no, internal functions run inside convex deployment, if you expose them to client, you expose to other servers as well like nextjs server funcions
No description
Patolord
Patolord•10h ago
the only way would be to not have a convex client running on your app but i dont see a reason for that
borisfyi
borisfyiOP•10h ago
I was thinking of maybe having 2 clients ? Like one for my backend only, and the other for the actual client. Thanks for the answer btw!

Did you find this page helpful?