Deploy your first function
This guide walks through writing a small function that greets a visitor by name and deploying it to the edge.
Project layout
Section titled “Project layout”A fresh nimbus init project looks like this:
Directorymy-app
Directoryfunctions
- hello.ts
- nimbus.config.ts
- package.json
Write the function
Section titled “Write the function”-
Open
functions/hello.tsand 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}!`);} -
Run it locally:
Terminal window nimbus devTerminal window curl "http://localhost:8787/hello?name=Ferris"# Hello, Ferris! -
Deploy to every region:
Terminal window nimbus deploy
Check it shipped
Section titled “Check it shipped”nimbus logs hello --tailYou should see a request logged for each invocation, including the region that served it.
Further reading
Section titled “Further reading”- Environment variables — pass secrets and config into a function.
- Custom domains — replace the generated
*.nimbus.devURL.