Skip to content

Backend function

Your own code running on Base44's servers instead of in the browser, for anything that needs a secret key or shouldn't be visible to users.

Anything in your frontend can be read by whoever opens dev tools. So code that uses a secret key, or decides who gets what, belongs in a backend function.

On Base44 they run on Deno, and the folder name becomes the function name. A small one:

ts
import { createClientFromRequest } from 'npm:@base44/sdk';

Deno.serve(async (req) => {
  const base44 = createClientFromRequest(req);
  const user = await base44.auth.me().catch(() => null);
  if (!user) return Response.json({ error: 'Sign in first' }, { status: 401 });
  return Response.json({ hello: user.email });
});

From the page you call it with base44.functions.invoke('name', data). Each function also gets its own URL, which is how webhooks reach it.

The gotcha: invoke gives you the whole HTTP response, so your data is on res.data. If a function seems to return nothing, check that before anything else.

Related:Secrets, Service role and Integration.

Where I've used it: