On this page

Quickstart

Create, deploy and call a function in a minute.

#1. Create the function

Open your project → Studio → Edge Functions → New function. Pick the Hello world template, name it hello-world and press Deploy function. The code:

index.ts
Deno.serve(async (req) => {
  const { name = 'world' } = await req.json().catch(() => ({}))
  return Response.json({ message: `Hello ${name}!` })
})

#2. Call it

The function is live right away. Call it with your project's anon key (Studio → API → Keys):

const { data, error } = await stitchdb.functions.invoke('hello-world', {
  body: { name: 'Ada' },
})
// data → { message: 'Hello Ada!' }

Or open the Test tab of the function, choose a method, body and key, and press Send request.

#3. Change it

Edit the code in the Code tab and press Deploy (or Ctrl/⌘ + S). Every deploy with changed code becomes a new version; the previous ones stay available under Settings → Roll back.

#Next

Add secrets for API keys (Environment and secrets), read data as the calling user (Examples), or deploy from CI with the management API.