MapleLeaf ๐ŸM
Convex Communityโ€ข4y agoโ€ข
18 replies
MapleLeaf ๐Ÿ

Environment variables in Convex functions

how do I use environment variables in convex functions? I tried something along these lines, but it gave me an error: Error: [CONVEX M(user:createUser)] Uncaught ReferenceError: process is not defined
export const createUser = mutation(
  async ({ db }, adminSecret: string, data: SimpleDocument<"user">) => {
    if (adminSecret !== process.env.ADMIN_SECRET) {
      throw new Error("Invalid admin secret")
    }
    // other stuff
  },
)
Was this page helpful?