DEV Community

Alex Spinov
Alex Spinov

Posted on

Val Town Has a Free API: Write and Deploy JavaScript Functions Instantly

What if deploying an API endpoint was as easy as writing a tweet? Val Town makes serverless functions feel like a REPL.

What Is Val Town?

Val Town is a platform where every function you write is instantly deployed as an API endpoint. No git push. No CI/CD. No infrastructure.

// This is immediately live at val.town/v/yourname/hello
export default function(req: Request): Response {
  return Response.json({ message: "Hello from Val Town!" })
}
Enter fullscreen mode Exit fullscreen mode

Save. It's deployed. You get a URL. That's the whole workflow.

Types of Vals

HTTP vals — API endpoints:

export default async function(req: Request): Response {
  const url = new URL(req.url)
  const name = url.searchParams.get("name") ?? "World"
  return Response.json({ greeting: \`Hello, \${name}!\` })
}
// GET https://yourname-hello.web.val.run?name=Alice
Enter fullscreen mode Exit fullscreen mode

Cron vals — Scheduled functions:

export default async function() {
  const res = await fetch("https://api.github.com/repos/denoland/deno")
  const { stargazers_count } = await res.json()
  console.log(\`Deno stars: \${stargazers_count}\`)
  // Runs every hour, day, etc.
}
Enter fullscreen mode Exit fullscreen mode

Email vals — Receive and process emails:

export default async function(email: Email) {
  console.log(\`From: \${email.from}, Subject: \${email.subject}\`)
  // You get a @valtown.email address that triggers this function
}
Enter fullscreen mode Exit fullscreen mode

Built-in Storage

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

// Key-value storage
await blob.setJSON("mydata", { count: 42 })
const data = await blob.getJSON("mydata")

// SQLite database
await sqlite.execute("CREATE TABLE IF NOT EXISTS visits (url TEXT, ts INTEGER)")
await sqlite.execute("INSERT INTO visits VALUES (?, ?)", [req.url, Date.now()])
Enter fullscreen mode Exit fullscreen mode

Why Val Town

  • Zero deployment — save = deploy
  • Free tier — generous limits for prototyping
  • Deno runtime — TypeScript, npm imports, Web APIs
  • Composable — import other people's vals
  • Social coding — discover and fork community vals

Perfect for: webhooks, cron jobs, API proxies, prototypes, bots, email handlers.


Building serverless tools? Check out my developer toolkit or email spinov001@gmail.com.

Top comments (0)