Functions
Write custom TypeScript or Python backend handlers and invoke them from your generated app. Multi-tenant Cloud Run hosting, no infrastructure to manage.
Functions require a Pro or Business plan. Free workspaces can read and view existing functions but cannot create or update them.
How Functions Work
A Function is a single source file (TypeScript or Python) attached to an app. Source code lives in Google Cloud Storage; a Firestore manifest tracks which functions an app has and their metadata. At runtime, GenMB's function host loads the source, validates it, and exposes a stable HTTPS endpoint your app can call.
There is no per-app server to provision. All apps share the same function host (a Cloud Run service) and the host loads code on demand, so a brand-new Function is reachable seconds after upload.
When to reach for a Function
Use a Function when a built-in Service does not cover your need: a custom webhook, a third-party integration that needs a secret, a long-running computation, or any logic that should not live in client code.Creating a Function
Open the Functions panel
Choose a name and runtime
Write or paste your source
Invoke from your app
PUT /api/apps/{appId}/functions/{name} with a body of {name, runtime, source}. Useful for CI, scripts, or syncing from a local repo.Runtimes
Both runtimes receive a request-like object and return a response. The exact shape mirrors what each ecosystem expects, so familiar Node.js or Python patterns work without translation.
TypeScript
Async default export. Receives a parsed JSON body and request headers; returns any JSON-serializable value.
export default async function ({ body, headers, query }) {
return { ok: true, received: body }
}Python
A top-level handler(event) function. Receives a dict with body, headers, and query; returns a dict.
def handler(event):
return {"ok": True, "received": event["body"]}Invoking a Function
From inside your generated app, call your function with a relative path. The platform handles routing to the function host and authenticates the call on your behalf.
const res = await fetch('/api/fn/my-handler', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ amount: 12.5 }),
})
const data = await res.json()You can also invoke directly from the editor (a small playground in the Functions panel) to test with sample input before wiring it into your UI.
Limits & Quotas
| Plan | Max functions / app | Invocations |
|---|---|---|
| Free | 3 | 100 / day |
| Pro | 20 | 50,000 / month |
| Business | 100 | Unlimited |
- Per-function source size: 100 KB.
- Per-invocation timeout: 30 seconds.
- Function name: alphanumeric (with
_or-), up to 64 characters. - Collaborators on your app inherit the owner's plan, so they are not blocked by their own Free quota.
Security
Functions execute in the multi-tenant function host with per-app isolation. Python functions are statically analyzed before execution; imports of dangerous modules are rejected at upload time.
Python import blocklist
For Python runtimes,os, subprocess, socket, and ctypes are not allowed. Use the SDK helpers injected into the runtime for network access and database calls instead of reaching for raw modules.Secrets your function needs (API keys, third-party tokens) belong in Environment Variables. Never paste secrets directly into source code.
Codegen Integration
When your prompt implies server-side logic, the code generator can emit Functions as part of the same pass. For example, asking GenMB for "an app that receives a Stripe webhook and updates a row" produces both the UI and a functions/stripe-webhook.ts file. After generation, the finalize step uploads the file and writes the manifest, so the function is live as soon as your app is ready to preview.
FAQs
What are GenMB Functions?▾
How are Functions different from Services?▾
Which runtimes are supported?▾
Are there limits on what a Python function can do?▾
How are Functions billed?▾
Can codegen create Functions for me?▾
Ready to build?
Create your first app for free, no credit card required.