Deploy, invoke, and monitor serverless functions running on the Functions optional service.
# List all deployed functions
nself functions list
# Deploy a function from the current directory
nself functions deploy send-welcome-email
# Invoke a function and print the response
nself functions invoke send-welcome-email --data '{"userId":"123"}'nself functions list [FLAGS]
nself functions deploy <NAME> [FLAGS]
nself functions invoke <NAME> [FLAGS]
nself functions logs <NAME> [FLAGS]nself functions manages the serverless Functions optional service. Functions are small, single-purpose HTTP handlers deployed into the nSelf runtime. They run inside the same Docker network as the rest of the stack, so they can query Postgres directly, call Hasura, or access any other service without going through the public internet.
Functions are stored in the functions/ directory at your project root. Each function is a subdirectory with an index.ts (or index.js) entry point. The runtime is Deno-based by default, with Node.js compatibility available via a flag.
The Functions service must be enabled in your environment before deploying. Run nself service enable functions if it is not already running.
Print all deployed functions, their runtime, status, and last deploy time.
nself functions list
# NAME RUNTIME STATUS DEPLOYED
# send-welcome-email deno running 2026-05-07 09:00
# process-webhook deno running 2026-05-06 14:30
# nightly-report deno stopped 2026-05-01 08:00Deploy or redeploy the named function. The CLI bundles thefunctions/<NAME>/ directory and sends it to the Functions service. If the function already exists, the running version is replaced with zero downtime.
nself functions deploy send-welcome-email
# Bundling functions/send-welcome-email/...
# Deploying to Functions service...
# send-welcome-email deployed. URL: https://api.local.nself.org/functions/v1/send-welcome-emailSend an HTTP POST to the named function and print the response. Useful for manual testing and debugging without needing a separate HTTP client.
nself functions invoke send-welcome-email --data '{"userId":"abc123"}'
nself functions invoke process-webhook --data @payload.json
nself functions invoke health-check --method GETStream live logs from a running function. Output includes timestamps and log levels.
nself functions logs send-welcome-email
# 2026-05-07T09:01:23Z INFO Function invoked with userId=abc123
# 2026-05-07T09:01:23Z INFO Email queued successfully
# ^C to stop| Flag | Type | Default | Description |
|---|---|---|---|
--data | string | JSON body for invoke. Use @file.json to read from a file | |
--method | string | POST | HTTP method for invoke |
--json | bool | false | Output list as JSON |
--env | string | active | Target environment |
--follow | bool | true | Keep streaming logs until interrupted (logs only) |
--tail | int | 50 | Number of recent log lines to show before streaming |
--node | bool | false | Deploy using Node.js runtime instead of Deno |
for fn in functions/*/; do
name=$(basename "$fn")
nself functions deploy "$name"
donenself functions invoke process-order --data @test/fixtures/order.jsonnself functions logs send-welcome-email &
pnpm test:integration
kill %1nself functions logs nightly-report --tail 100 --follow=falsenself functions list --json | jq '[.[] | select(.status == "stopped") | .name]'NSELF_ENV — default target environmentFUNCTIONS_JWT_SECRET — JWT secret used to authorize function invocations (set in env files)0 — success1 — generic error (service not running, deploy failed)2 — invalid arguments or function not foundinvoke: the HTTP response status is printed; a non-2xx response does not by itself cause a non-zero exit unless --fail is passed.