Captain
Captain2y ago

Where do convex functions run?

do convex functions only run in the client?
3 Replies
ian
ian2y ago
The only run in the server Assuming you mean query, mutation, action. But the types are shared with the client
Captain
CaptainOP2y ago
the console.log of the following gets printed in the browser console.
export const get = query({
args: {},
handler: async (ctx) => {
console.log("get tasks");
return await ctx.db.query("tasks").collect();
},
});
export const get = query({
args: {},
handler: async (ctx) => {
console.log("get tasks");
return await ctx.db.query("tasks").collect();
},
});
im using the next.js example from the convex docs makes sense tho right? given this function is called inside a client component?
ian
ian2y ago
The logs are sent down to the client, in your dev instance. Thankfully, this runs really close to the database in the server so it has fast access to do repeated database queries. And hide data from clients, do auth, etc In production we don’t send down the console logs, in case you accidentally log something sensitive. It just feels like it’s running in the client because it’s so smooth 😎

Did you find this page helpful?