Skip to main content

Runtimes & Languages

Invoke supports multiple languages and runtimes. Every function you create targets one language and runtime combination.

Supported Runtimes

LanguageRuntimeSDK / Package
JavaScriptBunBuilt-in globals (kv, fetch, Router, RealtimeNamespace)
TypeScriptBuninvoke-types (type definitions only)
C#.NET 10 (NativeAOT)Invoke.SDK NuGet package

Function Types

Each language supports three function types:

TypeDescription
Simple FunctionHandles all requests with a single entry point handler
Multi-Route AppHandles multiple routes with a router (HTTP method + path matching)
Realtime HandlerHandles Socket.IO-style events over a persistent WebSocket namespace

Function Signatures

Simple Function

export default async function handler(req, res) {
res.json({ message: 'Hello, World!' })
}

Multi-Route App

const router = new Router()

router.get('/', (req, res) => res.json({ ok: true }))
router.get('/users/:id', (req, res) => res.json({ id: req.params.id }))
router.post('/users', async (req, res) => res.status(201).json(req.body))

export default router

Realtime Handler

const ns = new RealtimeNamespace('/chat')

ns.socket.on('$connect', function () {
ns.socket.join('lobby')
})

ns.socket.on('message', function (data) {
ns.socket.to('lobby').emit('message', data)
})

export default ns

Project Structure

my-function/
├── index.js # Entry point (exports default handler or router)
└── package.json # Package config (type: "module")

package.json:

{
"name": "my-function",
"version": "1.0.0",
"type": "module",
"main": "index.js"
}

Choosing a Runtime

ScenarioRecommended
Quick scripting, prototypingJavaScript (Bun)
Type-safe functions, npm ecosystemTypeScript (Bun)
High-performance, type-safe, low latencyC# (.NET)

See the API Reference for full Bun API documentation, or the .NET API Reference for the C# SDK.