docs›Edge Functions›Your first function Your first Edge Function
You will write a function, deploy it to your project, call it from Node.js and read its result. Every command below was run for real.
10 min read·Level beginner·Revised on Oct 12, 2026
This English text was generated automatically from the French original and has not been reviewed yet.
#Requirements
Before you start
You need:
- Node.js 20 or later.
- The
aura CLI. Install it with npm install -g @aurabase/cli (see the CLI reference for other platforms).
- An Aurabase account.
The CLI speaks French today
The aura CLI prints its messages in French. The outputs below are copied from real runs, not translated.
#Project
1. Create and link a project
Sign in, create a project, and link your working folder to it. Replace <org-slug> with the slug shown by aura orgs list.
terminalbash
aura login --email you@example.com --password '<your-password>'
aura orgs list
aura projects create my-app --org <org-slug>
The last command prints the project URL and your first API keys. Copy them now: the initial keys are shown only once. If you miss them, create new ones in the Studio under Settings, API keys.
outputtext
✔ Projet créé : my-app (e99f2c4f-43e2-4d08-b023-b4f9e687d17c)
import { createClient } from '@aurabase/aurabase-js'
const client = createClient('http://my-app-ajap5iw2.localhost:8080', 'aura_anon_…')
Link the current folder to the project:
terminalbash
aura link --project-id e99f2c4f-43e2-4d08-b023-b4f9e687d17c
outputtext
✔ Projet e99f2c4f-… lié dans aurabase.toml.
• URL du projet : http://my-app-ajap5iw2.localhost:8080
Then tell the CLI where the data plane is and which key to use. A service_role key is required to deploy, because deploying code is an administrative action.
.envbash
AURA_PROJECT_URL=http://my-app-ajap5iw2.localhost:8080
AURA_API_KEY=<your service_role key>
Keep the service_role key on your machine
A service_role key bypasses row-level security and can deploy code. Never put it in a browser bundle or commit .env.
#Code
2. Write the function
terminalbash
aura functions new hello
outputtext
✔ Nouvelle fonction créée dans aurabase/functions/hello (gabarit TypeScript Deno)
Open aurabase/functions/hello/index.ts and replace its content:
aurabase/functions/hello/index.tstypescript
Deno.serve(async (req: Request) => {
const { name = 'world' } = await req.json().catch(() => ({}))
return new Response(JSON.stringify({ greeting: `Hello, ${name}!` }), {
headers: { 'content-type': 'application/json' },
})
})
A function must call Deno.serve. An export default is never called.
terminalbash
aura functions deploy hello
outputtext
✔ Détection script TypeScript (runtime: deno)...
• Envoi vers le service (runtime: deno)...
✔ Fonction 'hello' déployée avec succès !
Call it once from the CLI to check that it answers:
terminalbash
aura functions invoke hello --data '{"name":"Ada"}'
outputtext
✔ Réponse (200) :
{
"data": {
"body": { "greeting": "Hello, Ada!" },
"duration_ms": 74,
…
#SDK
4. Call it from the SDK
terminalbash
mkdir hello-client && cd hello-client
npm init -y
npm install @aurabase/aurabase-js
hello.mjstypescript
import { createClient } from '@aurabase/aurabase-js'
const aura = createClient(process.env.AURA_PROJECT_URL, process.env.AURA_ANON_KEY)
const { data, error } = await aura.functions.invoke('hello', { body: { name: 'Ada' } })
if (error) throw error
console.log(data.greeting)
terminalbash
AURA_PROJECT_URL=http://my-app-ajap5iw2.localhost:8080 AURA_ANON_KEY=aura_anon_… node hello.mjs
You called a function with the public anon key. That is the only call a public key can make: see who can call what.
Last updated · Oct 12, 2026