Skip to main content

Hello World Example

The simplest Invoke function examples.

Basic Hello World

export default function handler(req, res) {
res.json({
message: 'Hello World!',
timestamp: new Date().toISOString()
})
}

Test:

curl http://<your invoke-execution URL>/invoke/{functionId}

Response:

{
"message": "Hello World!",
"timestamp": "2026-02-10T12:00:00.000Z"
}

With Query Parameters

export default function handler(req, res) {
const name = req.query.name || 'World'
const greeting = req.query.greeting || 'Hello'

res.json({
message: `${greeting}, ${name}!`,
timestamp: new Date().toISOString()
})
}

Test:

curl "http://<your invoke-execution URL>/invoke/{functionId}?name=Alice&greeting=Hi"

Response:

{
"message": "Hi, Alice!",
"timestamp": "2026-02-10T12:00:00.000Z"
}

Async Hello World

export default async function handler(req, res) {
// Simulate async operation
await sleep(100)

res.json({
message: 'Hello from async function!',
timestamp: new Date().toISOString()
})
}

Request Information

export default function handler(req, res) {
res.json({
message: 'Hello World!',
request: {
method: req.method,
path: req.path,
query: req.query,
headers: {
userAgent: req.get('user-agent'),
host: req.get('host')
}
},
timestamp: new Date().toISOString()
})
}

Different Response Formats

JSON

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

Plain Text

export default function handler(req, res) {
res.send('Hello World!')
}

HTML

export default function handler(req, res) {
res.type('html').send(`
<!DOCTYPE html>
<html>
<head><title>Hello</title></head>
<body>
<h1>Hello World!</h1>
<p>Timestamp: ${new Date().toISOString()}</p>
</body>
</html>
`)
}

Next Steps