← All Templates

Cloudflare Worker

JavaScriptBeginnerBackend

Edge computing with Cloudflare Workers. Runs in 300+ cities worldwide with D1 database and KV storage.

Features

Code Preview

export default {
  async fetch(request, env) {
    const url = new URL(request.url);
    if (url.pathname === '/api/data') {
      const rows = await env.DB.prepare(
        'SELECT * FROM items LIMIT 10'
      ).all();
      return Response.json(rows.results);
    }
    return new Response('Hello from the edge!');
  },
};
Open in RoadCode

Related Templates

Express API
JavaScript · Beginner
Flask API
Python · Beginner
Django App
Python · Intermediate
FastAPI
Python · Intermediate