Deploy an API endpoint in under a minute
An HTTP val is a fetch handler with a public URL: you write a function that takes a web-standard Request and returns a Response, and it's live at its own URL as soon as you save. There's no Dockerfile, no deploy pipeline, and nothing to provision.
The endpoint
This is a complete JSON API with one parameterized route, using Hono — the router we typically recommend:
import { Hono } from "npm:hono";
const app = new Hono();
app.get("/greet/:name", (c) =>
c.json({ message: `Hello, ${c.req.param("name")}!` })
);
export default app.fetch;If you don't need routes, skip Hono entirely and export a plain handler:
export default async function (req: Request): Promise<Response> {
return Response.json({ ok: true });
}Set it up
- Create a val and add a file.
- Click the
+button in the top right of the editor and selectHTTP. - Paste in the code above and save. The HTTP trigger shows your endpoint
URL — something like
yourname-api.web.val.run.
Then hit it from your terminal:
curl https://yourname-api.web.val.run/greet/world{ "message": "Hello, world!" }Requests to any path on that subdomain are routed to your file, so the
/greet/:name route just works.
What you get for free
- HTTPS — the endpoint URL is HTTPS from the start, no certificates to manage.
- Logs and traces — every request shows up in the val's logs, including
anything you
console.log. - Instant redeploys — every save deploys and is automatically versioned, and rollbacks are instantaneous.
Next steps
- HTTP reference — basic examples, routing, JSX, and custom domains
- Put a form online and save submissions — a complete HTTP val that serves pages and stores data
Last updated