Skip to content

Serverless handlers

Goal: Structure edge and serverless entrypoints in SJS.

Scaffold templates with superjs init workers-api or lambda-handler. For a full Node backend, see mvb-fastify.

Example

export async function fetch(request: dynamic): Promise<dynamic> {
  const url: dynamic = new URL(request.url as string)
  const path: string = url.pathname as string
  if (path === "/health") {
    return new Response("ok", { status: 200 })
  }
  return new Response("not found", { status: 404 })
}

Open in playground

Key takeaways

  • Handlers take dynamic at the platform boundary.
  • Use match on paths and event shapes.
  • Not decorators — serverless export handlers only.

Next: Tooling tour

Documentation