scribase
Guide

Deploy an edge function on Scribase

Edge functions run server-side logic close to your data on the compatible /functions/v1 path. Scribase runs the open-source Deno edge-runtime per environment; you deploy a function by sending its source to the authenticated /v1 API (directly or through the scribase SDK), then list and invoke it through the same API so a person or an agent can verify exactly what is running.

Published September 23, 20266 min read

1.Write the function

A function is a module that serves requests. From the CLI, scribase functions deploy acme store production hello ./functions/hello does the same upload in one step. The runtime hands every function the environment's database URL and JWT secret (DATABASE_URL, SUPABASE_DB_URL, SCRIBASE_DB_URL, and JWT_SECRET), so it reaches your database and verifies the same tokens as the rest of the stack without a second credential system.

ts
// functions/hello/index.ts
Deno.serve(async (req: Request): Promise<Response> => {
  const { name } = await req.json()
  return Response.json({ hello: name })
})

2.Deploy it through the control API

POST the function name and source to the environment's functions route. A deploy creates or replaces the function and, unlike a read, surfaces a real error if the runtime rejects it. From TypeScript the same call is scribase.functions.deploy(ref, { name, source }).

bash
$ jq -n --arg source "$(cat functions/hello/index.ts)" '{name: "hello", source: $source}' \
  | curl -X POST "$SCRIBASE_API_URL/v1/organizations/acme/projects/store/environments/production/functions" \
      -H "Authorization: Bearer $SCRIBASE_ACCESS_TOKEN" \
      -H 'Content-Type: application/json' --data-binary @-

{"function":"hello","result":{…}}

3.Smoke-test it, then call it on the compatible path

Invoke the function through the control API to confirm the deploy, then call it on /functions/v1 from your app exactly as you do today — by changing the URL and keys.

bash
$ curl -X POST "$SCRIBASE_API_URL/v1/organizations/acme/projects/store/environments/production/functions/hello/invoke" \
    -H "Authorization: Bearer $SCRIBASE_ACCESS_TOKEN" \
    -H 'Content-Type: application/json' -d '{ "name": "world" }'
{"function":"hello","result":{"hello":"world"}}
FAQ

Common questions

Does my existing edge function code run unchanged?

Yes. Scribase runs the same open-source Deno edge-runtime and serves functions on the compatible /functions/v1 path, so existing function code and the clients that call it work by changing the URL and keys.

Is there a CLI command for deploys?

Yes. scribase functions deploy <org> <project> <env> <name> ./functions/<name> uploads a function directory as a new immutable version, and scribase functions invoke, logs, rollback, and delete cover the rest of the lifecycle. The same calls are available on the /v1 API and in the TypeScript SDK (functions.deploy). Locally, scribase dev serves whatever is in the functions root.

Ready to try it?

Start a free project and follow this guide against a real backend, or move an existing project in with a dry run first.