Skip to content

Edge Functions Overview

Pulsabase Edge Functions let you run custom server-side logic close to your data. Functions are defined as a sequence of typed steps — HTTP requests, database queries, transforms, conditionals, emails, and more — without managing infrastructure.

// Synchronous — waits for the full result
const result = await pb.edge('send-welcome-email').invoke({
userId: 'abc-123',
});
// Async — fire and forget (does not block)
await pb.edge('log-activity').invokeAsync({ userId: 'abc-123' });

Edge functions can run in two modes, chosen per invocation:

ModeSDK MethodBehavior
Synchronous.invoke(payload)Waits for the full result. Use for functions where you need the output (e.g., data enrichment, validation).
Asynchronous.invokeAsync(payload)Returns immediately with { "queued": true }. The function runs in the background. Use for side effects (emails, notifications, logging).

Before hooks are always synchronous (they block the DB mutation). After hooks are always asynchronous (they run post-mutation).

Edge functions are managed in Dashboard → Edge Functions:

  1. Click Create Function
  2. Name your function (used for invocation and webhook URLs)
  3. Add steps using the visual flow builder
  4. Test with the built-in dry-run executor
  5. Save — the function is immediately available
Step TypeDescription
HTTPMake outbound HTTP requests to external APIs
DatabaseExecute queries against your Pulsabase database
TransformManipulate data with JavaScript expressions
ConditionBranch the sequence based on a boolean expression
LoopIterate over an array from a previous step
EmailSend emails via SMTP (Pulsabase-managed or your own)
LogOutput current variables to the execution __logs

Step outputs are available to subsequent steps using {{}} syntax:

{{steps.<step_name>.body.<field>}} ← Output of a previous step
{{input.<field>}} ← The invocation payload
{{env.STRIPE_KEY}} ← Secure environment variable
{{jwt.sub}} ← Current user's ID from JWT
{{jwt.role}} ← Current user's role

This is a process-order function that validates stock, conditionally errors, creates the order, and sends a confirmation email:

Test any function without triggering real side effects — emails are not sent, HTTP calls are made but clearly flagged.

const result = await pb.edge('process-order').dryRun().invoke({
productId: 'p-123',
quantity: 2,
});
// Step-by-step execution log
console.log(result.__logs);