CLOUDFLARE: EDGE
Infrastructure that disappears.
<50ms cold starts. Global by default.
Why Edge Computing?
Traditional servers run in one place. Edge functions run everywhere.
- <50ms cold starts (no Lambda lag)
- 300+ global locations
- No regional configuration
- Data colocated with compute
The infrastructure recedes. Only the response remains.
"The tool is genuinely itself only when it withdraws into equipmentality."— Martin Heidegger, Being and Time
┌─────────────────────────────────────────────────────────────────────────┐ │ │ │ CREATE SOMETHING INFRASTRUCTURE │ │ Per-package isolation, global deployment │ │ │ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌───────────┐ │ │ │ .space │ │ .io │ │ .agency │ │ .ltd │ │ │ │ Practice │ │ Research │ │ Services │ │Philosophy │ │ │ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ └─────┬─────┘ │ │ │ │ │ │ │ │ ▼ ▼ ▼ ▼ │ │ ┌──────────────────────────────────────────────────────────────────┐ │ │ │ Cloudflare Edge Network │ │ │ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │ │ │ │ Pages │ │ Workers │ │ D1 │ │ KV │ │ │ │ │ │ (SSR) │ │(Compute) │ │ (SQLite) │ │ (Cache) │ │ │ │ │ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │ │ │ │ ┌──────────┐ │ │ │ │ │ R2 │ │ │ │ │ │ (Storage)│ │ │ │ │ └──────────┘ │ │ │ └──────────────────────────────────────────────────────────────────┘ │ │ │ └─────────────────────────────────────────────────────────────────────────┘
Each package has its own D1, KV, and R2 bindings.
D1: Edge SQLite
Full SQL at the edge. Not a key-value store—a real database.
- SQLite semantics, globally replicated
- ACID transactions
- Read replicas at every edge location
- Millisecond queries worldwide
The database disappears. Only the data remains.
D1 Queries
// Simple query with parameter binding
const result = await db.prepare(
'SELECT * FROM users WHERE id = ?'
).bind(userId).first();
// Multiple results
const { results } = await db.prepare(
'SELECT * FROM posts ORDER BY created_at DESC'
).all();
// Batch operations (atomic)
const batch = await db.batch([
db.prepare('INSERT INTO logs VALUES (?)').bind('start'),
db.prepare('UPDATE status SET running = 1'),
]); Prepared statements. Parameter binding. Familiar SQL.
KV: Key-Value Cache
Globally distributed key-value storage. Eventually consistent.
- Sub-millisecond reads at the edge
- Automatic replication worldwide
- TTL-based expiration
- Metadata per key
Use for: sessions, cached API responses, feature flags.
KV Operations
// Get with metadata
const { value, metadata } = await kv.getWithMetadata(
key, { type: 'json' }
);
// Put with expiration
await kv.put(key, JSON.stringify(data), {
expirationTtl: 3600, // 1 hour
metadata: { created: Date.now() }
});
// List with prefix (pagination)
const { keys } = await kv.list({ prefix: 'user:' }); Simple API. Automatic replication. Global reads.
R2: Object Storage
S3-compatible object storage. Zero egress fees.
- Store files, images, assets
- S3 API compatible
- No bandwidth charges for reads
- Integrate with Workers for processing
Use for: user uploads, static assets, backups.
Workers: Edge Compute
JavaScript/TypeScript functions at every edge location.
- <50ms cold starts (not seconds)
- V8 isolates, not containers
- Standard Web APIs (fetch, crypto, etc.)
- Can access D1, KV, R2 directly
Workers are the compute layer. Everything else is storage.
Pages: Full-Stack Deployment
SvelteKit on Pages = SSR at the edge.
- Automatic builds from Git
- Preview deployments per branch
- SSR via integrated Workers
- Static assets cached globally
Push to Git. Deployment happens. Infrastructure disappears.
┌─────────────────────────────────────────────────────────────────────────┐ │ │ │ PROJECT NAMES │ │ Historical inconsistency — look up, don't guess │ │ │ │ ┌────────────────┬───────────────────────────┬───────────────────┐ │ │ │ Package │ Cloudflare Project │ Pattern │ │ │ ├────────────────┼───────────────────────────┼───────────────────┤ │ │ │ space │ create-something-space │ create-something- │ │ │ │ io │ create-something-io │ create-something- │ │ │ │ agency │ create-something-agency │ create-something- │ │ │ ├────────────────┼───────────────────────────┼───────────────────┤ │ │ │ ltd │ createsomething-ltd │ createsomething- │ │ │ │ lms │ createsomething-lms │ createsomething- │ │ │ └────────────────┴───────────────────────────┴───────────────────┘ │ │ │ │ Reference: .claude/rules/PROJECT_NAME_REFERENCE.md │ │ │ └─────────────────────────────────────────────────────────────────────────┘
Wrong name = new project. Production breaks.
Type Generation
# Generate types before development
pnpm --filter=space exec wrangler types
# Creates worker-configuration.d.ts:
interface Env {
DB: D1Database;
KV: KVNamespace;
BUCKET: R2Bucket;
// ... other bindings from wrangler.toml
}
# Run after changing bindings
# Types enable autocomplete and type safety Types are generated, not written. Bindings become typed.
Platform Access Pattern
// +page.server.ts or +server.ts
import type { PageServerLoad } from './$types';
export const load: PageServerLoad = async ({ platform }) => {
// Access bindings via platform.env
const db = platform?.env.DB;
const kv = platform?.env.KV;
const bucket = platform?.env.BUCKET;
// Use them
const user = await db.prepare(
'SELECT * FROM users WHERE id = ?'
).bind(1).first();
return { user };
}; platform.env holds all bindings. Access anywhere server-side.
API Routes
// src/routes/api/users/+server.ts
import { json, error } from '@sveltejs/kit';
import type { RequestHandler } from './$types';
export const GET: RequestHandler = async ({ platform }) => {
const db = platform?.env.DB;
const { results } = await db.prepare(
'SELECT id, name FROM users'
).all();
return json({ users: results });
};
export const POST: RequestHandler = async ({ request, platform }) => {
const { name } = await request.json();
// Insert user...
return json({ success: true });
}; Standard SvelteKit patterns. Edge execution.
SDK for Composed Operations
// For complex operations, use the SDK
import { cf } from '@create-something/cloudflare-sdk';
// Composed KV operations
const namespaces = await cf.kv.listNamespaces();
const value = await cf.kv.get('namespace-id', 'key');
// D1 queries across databases
const users = await cf.d1.query('my-db', 'SELECT * FROM users');
// Pages deployment
const url = await cf.pages.deploy('project', './dist'); SDK for multi-step operations. Direct bindings for simple queries.
Zuhandenheit Applied
When edge infrastructure works, you don't think about it.
- No region selection — it's everywhere
- No cold start delays — it's instant
- No scaling configuration — it's automatic
- No egress bills — it's free
You think about the user experience. The infrastructure serves silently.
The Edge Disappears
You don't think about latency.
You think about users.