DEV Community

Alex Spinov
Alex Spinov

Posted on

Val Town Is Free — Write and Deploy API Endpoints From Your Browser

Serverless Functions Without the Server Setup

Val Town lets you write JavaScript/TypeScript functions in your browser and instantly get an HTTP endpoint. No deployment, no hosting, no configuration.

Free tier: unlimited vals, 10 runs/second.

Hello World

Go to val.town, create an account, and write:

export default function(req: Request) {
  return Response.json({ message: "Hello from Val Town!", time: new Date().toISOString() });
}
Enter fullscreen mode Exit fullscreen mode

You instantly get a URL like https://username-funcname.web.val.run that works.

Build a Webhook Handler

export default async function(req: Request) {
  if (req.method !== "POST") return new Response("POST only", { status: 405 });

  const body = await req.json();

  // Process webhook
  console.log("Received:", body);

  // Forward to Telegram
  await fetch(`https://api.telegram.org/bot${Deno.env.get("TG_TOKEN")}/sendMessage`, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ chat_id: "123", text: JSON.stringify(body, null, 2) })
  });

  return Response.json({ ok: true });
}
Enter fullscreen mode Exit fullscreen mode

Scheduled Functions (Cron)

export default async function() {
  // This runs on a schedule you set in the UI
  const r = await fetch("https://api.github.com/users/octocat");
  const data = await r.json();
  console.log(`Followers: ${data.followers}`);
}
Enter fullscreen mode Exit fullscreen mode

Store Data (SQLite Built-in)

import { sqlite } from "https://esm.town/v/std/sqlite";

await sqlite.execute("CREATE TABLE IF NOT EXISTS visits (url TEXT, ts TEXT)");
await sqlite.execute("INSERT INTO visits VALUES (?, ?)", [req.url, new Date().toISOString()]);

const { rows } = await sqlite.execute("SELECT COUNT(*) as count FROM visits");
return Response.json({ total_visits: rows[0][0] });
Enter fullscreen mode Exit fullscreen mode

Val Town vs Alternatives

Feature Val Town Deno Deploy CF Workers
Browser IDE Yes No Yes
Instant deploy Yes CLI needed CLI needed
SQLite Built-in KV only D1
Email sending Built-in No No
Cron Built-in Built-in Triggers
Learning curve 5 min 30 min 1 hour

Perfect for prototyping, webhooks, bots, and small automation tasks.


More | GitHub


More from me: 10 Dev Tools I Use Daily | 77 Scrapers on a Schedule | 150+ Free APIs

Top comments (0)