client.functions.deploy
Deploy or update an edge function.
Signature
class Client {
functions: {
deploy(name: string, code: string, opts?: { trigger?: string; cronSchedule?: string }): Promise<void>
}
}
Parameters
| Name | Type | Required | Notes |
|---|---|---|---|
| string | yes | Function name (unique per-project) |
| string | yes | JavaScript/TypeScript source code |
| string | no | HTTP endpoint path (e.g. ) |
| string | no | Cron expression for scheduled runs |
Throws
| Error | Condition |
|---|---|
| Invalid function name or code |
| Invalid or expired API key |
Examples
HTTP-triggered function:
await bf.functions.deploy('hello', `
export default async (req) => {
return { body: \`Hello \${req.name}!\` }
}`, { trigger: '/hello' })
Scheduled function:
await bf.functions.deploy('daily-report', `
export default async () => {
await runReport()
}`, { cronSchedule: '0 6 * * *' })
Pitfalls
- Code size limit — 500 KB max per function
- Trigger conflicts — two functions cannot share the same trigger path
- Hot redeploy — existing invocations drain before new code takes effect
See also
{auto-injected}
Tested against
{auto-injected}