Skip to content

Deploy your first function

This guide walks through writing a small function that greets a visitor by name and deploying it to the edge.

A fresh nimbus init project looks like this:

  • Directorymy-app
    • Directoryfunctions
      • hello.ts
    • nimbus.config.ts
    • package.json
  1. Open functions/hello.ts and replace its contents:

    functions/hello.ts
    export default function handler(request: Request) {
    const url = new URL(request.url);
    const name = url.searchParams.get('name') ?? 'world';
    return new Response(`Hello, ${name}!`);
    }
  2. Run it locally:

    Terminal window
    nimbus dev
    Terminal window
    curl "http://localhost:8787/hello?name=Ferris"
    # Hello, Ferris!
  3. Deploy to every region:

    Terminal window
    nimbus deploy
Terminal window
nimbus logs hello --tail

You should see a request logged for each invocation, including the region that served it.