Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.edgespark.dev/llms.txt

Use this file to discover all available pages before exploring further.

The EdgeSpark runtime gives your server code a typed SDK for platform services. You import what you need from edgespark and edgespark/http, then use those values inside route handlers. This page is about the server runtime. For browser code in the scaffolded web/ app, use @edgespark/web.

Runtime pattern

Your entry point exports a static Hono app:
server/src/index.ts
import { db } from "edgespark";
import { auth } from "edgespark/http";
import { Hono } from "hono";
import { posts } from "@defs";

const app = new Hono().get("/api/posts", async (c) => {
  const rows = await db.select().from(posts);

  return c.json({
    posts: rows,
    userEmail: auth.user.email,
  });
});

export default app;
The SDK values are request-scoped, so you use them inside handlers rather than configuring them yourself.

Client shape

The runtime is split into focused imports:
  • db from edgespark for Drizzle database access
  • storage from edgespark for R2 operations
  • secret from edgespark for encrypted secrets
  • vars from edgespark for plain environment variables
  • ctx from edgespark for request-scoped helpers such as runInBackground() and environment
  • auth from edgespark/http for the current authenticated user and auth helpers

db

A Drizzle ORM instance connected to your project’s D1 database:
const rows = await db.select().from(posts);
See the database SDK reference for the full API.

auth

Authentication state for the current request:
const email = auth.user.email;
Routes under /api/* require login. Routes under /api/public/* allow anonymous access. See path-based auth.

storage

Typed access to your declared buckets:
const object = await storage.from(buckets.uploads).get("docs/report.pdf");
See the storage SDK reference for the full API.

secret

Reads environment-scoped secrets:
const apiKey = secret.get("STRIPE_SECRET_KEY");
See manage secrets for the CLI workflow.

vars

Reads plain runtime configuration:
const apiBaseUrl = vars.get("PUBLIC_API_BASE_URL");
See the vars SDK reference for the runtime API.

ctx

Request-scoped helpers:
ctx.runInBackground(sendAnalyticsEvent());

if (ctx.environment === "production") {
  // Production-only behavior
}

Generated types

The runtime SDK is typed from generated files in server/src/__generated__/. Run edgespark pull types whenever you need to refresh those declarations.

See also

SDK overview

The full SDK reference index for database, auth, storage, secrets, and context.

Project structure

Where generated types and repo-authored defs live in the scaffold.
Last modified on April 7, 2026