hono-cloudflare
Hono on Cloudflare Workers - bindings, KV, D1, R2, Durable Objects, and edge deployment patterns
What this skill does
# Hono on Cloudflare Workers
## Overview
Hono was originally built for Cloudflare Workers and provides first-class support for the entire Cloudflare ecosystem including KV, D1, R2, Durable Objects, Queues, and more.
**Key Features**:
- Native Workers support
- Type-safe bindings access
- KV, D1, R2, Durable Objects integration
- Static asset serving
- Cloudflare Pages support
- Queue and scheduled handlers
## When to Use This Skill
Use Hono on Cloudflare when:
- Building edge APIs with global distribution
- Need serverless SQLite with D1
- Building real-time apps with Durable Objects
- Storing files with R2
- Need fast key-value storage with KV
- Deploying full-stack apps to Pages
## Quick Start
### Create New Project
```bash
npm create hono@latest my-app
# Select: cloudflare-workers
cd my-app
npm install
npm run dev
```
### Project Structure
```
my-app/
├── src/
│ └── index.ts # Main entry point
├── wrangler.toml # Cloudflare configuration
├── package.json
└── tsconfig.json
```
### Basic Application
```typescript
// src/index.ts
import { Hono } from 'hono'
const app = new Hono()
app.get('/', (c) => c.text('Hello Cloudflare Workers!'))
export default app
```
### Deploy
```bash
# Deploy to Cloudflare
npx wrangler deploy
# Local development
npx wrangler dev
```
## Environment Bindings
### Typed Bindings
```typescript
import { Hono } from 'hono'
// Define your bindings
type Bindings = {
// Environment variables
API_KEY: string
DATABASE_URL: string
// KV Namespaces
MY_KV: KVNamespace
// D1 Databases
DB: D1Database
// R2 Buckets
BUCKET: R2Bucket
// Durable Objects
COUNTER: DurableObjectNamespace
// Queues
MY_QUEUE: Queue
}
const app = new Hono<{ Bindings: Bindings }>()
app.get('/config', (c) => {
// Fully typed access
const apiKey = c.env.API_KEY
return c.json({ configured: !!apiKey })
})
export default app
```
### wrangler.toml Configuration
```toml
name = "my-app"
main = "src/index.ts"
compatibility_date = "2024-01-01"
[vars]
API_KEY = "your-api-key" # pragma: allowlist secret
[[kv_namespaces]]
binding = "MY_KV"
id = "your-kv-id"
[[d1_databases]]
binding = "DB"
database_name = "my-database"
database_id = "your-d1-id"
[[r2_buckets]]
binding = "BUCKET"
bucket_name = "my-bucket"
[[queues.producers]]
binding = "MY_QUEUE"
queue = "my-queue"
```
## KV Storage
### Basic Operations
```typescript
type Bindings = {
CACHE: KVNamespace
}
const app = new Hono<{ Bindings: Bindings }>()
// Get value
app.get('/cache/:key', async (c) => {
const key = c.req.param('key')
const value = await c.env.CACHE.get(key)
if (!value) {
return c.json({ error: 'Not found' }, 404)
}
return c.json({ key, value })
})
// Get JSON value
app.get('/cache/:key/json', async (c) => {
const key = c.req.param('key')
const value = await c.env.CACHE.get(key, 'json')
return c.json({ key, value })
})
// Set value
app.put('/cache/:key', async (c) => {
const key = c.req.param('key')
const body = await c.req.json()
await c.env.CACHE.put(key, JSON.stringify(body), {
expirationTtl: 3600 // 1 hour
})
return c.json({ success: true })
})
// Delete value
app.delete('/cache/:key', async (c) => {
const key = c.req.param('key')
await c.env.CACHE.delete(key)
return c.json({ success: true })
})
// List keys
app.get('/cache', async (c) => {
const prefix = c.req.query('prefix') || ''
const list = await c.env.CACHE.list({ prefix, limit: 100 })
return c.json({ keys: list.keys })
})
```
### KV with Metadata
```typescript
interface UserMeta {
createdAt: string
role: string
}
app.put('/users/:id', async (c) => {
const id = c.req.param('id')
const user = await c.req.json()
await c.env.CACHE.put(`user:${id}`, JSON.stringify(user), {
metadata: {
createdAt: new Date().toISOString(),
role: user.role
} as UserMeta
})
return c.json({ success: true })
})
app.get('/users/:id', async (c) => {
const id = c.req.param('id')
const { value, metadata } = await c.env.CACHE.getWithMetadata<UserMeta>(`user:${id}`, 'json')
if (!value) {
return c.json({ error: 'Not found' }, 404)
}
return c.json({ user: value, metadata })
})
```
## D1 Database
### Basic Queries
```typescript
type Bindings = {
DB: D1Database
}
const app = new Hono<{ Bindings: Bindings }>()
// Select all
app.get('/users', async (c) => {
const { results } = await c.env.DB
.prepare('SELECT * FROM users ORDER BY created_at DESC')
.all()
return c.json({ users: results })
})
// Select one
app.get('/users/:id', async (c) => {
const id = c.req.param('id')
const user = await c.env.DB
.prepare('SELECT * FROM users WHERE id = ?')
.bind(id)
.first()
if (!user) {
return c.json({ error: 'Not found' }, 404)
}
return c.json({ user })
})
// Insert
app.post('/users', async (c) => {
const { name, email } = await c.req.json()
const result = await c.env.DB
.prepare('INSERT INTO users (name, email) VALUES (?, ?)')
.bind(name, email)
.run()
return c.json({
success: result.success,
id: result.meta.last_row_id
}, 201)
})
// Update
app.put('/users/:id', async (c) => {
const id = c.req.param('id')
const { name, email } = await c.req.json()
const result = await c.env.DB
.prepare('UPDATE users SET name = ?, email = ? WHERE id = ?')
.bind(name, email, id)
.run()
return c.json({ success: result.success })
})
// Delete
app.delete('/users/:id', async (c) => {
const id = c.req.param('id')
const result = await c.env.DB
.prepare('DELETE FROM users WHERE id = ?')
.bind(id)
.run()
return c.json({ success: result.success })
})
```
### Batch Operations
```typescript
app.post('/users/batch', async (c) => {
const { users } = await c.req.json()
const statements = users.map((user: { name: string; email: string }) =>
c.env.DB
.prepare('INSERT INTO users (name, email) VALUES (?, ?)')
.bind(user.name, user.email)
)
const results = await c.env.DB.batch(statements)
return c.json({
success: results.every(r => r.success),
count: results.length
})
})
```
## R2 Object Storage
```typescript
type Bindings = {
BUCKET: R2Bucket
}
const app = new Hono<{ Bindings: Bindings }>()
// Upload file
app.post('/files/:key', async (c) => {
const key = c.req.param('key')
const body = await c.req.arrayBuffer()
const contentType = c.req.header('Content-Type') || 'application/octet-stream'
await c.env.BUCKET.put(key, body, {
httpMetadata: { contentType }
})
return c.json({ success: true, key })
})
// Download file
app.get('/files/:key', async (c) => {
const key = c.req.param('key')
const object = await c.env.BUCKET.get(key)
if (!object) {
return c.json({ error: 'Not found' }, 404)
}
const headers = new Headers()
headers.set('Content-Type', object.httpMetadata?.contentType || 'application/octet-stream')
headers.set('ETag', object.httpEtag)
return new Response(object.body, { headers })
})
// Delete file
app.delete('/files/:key', async (c) => {
const key = c.req.param('key')
await c.env.BUCKET.delete(key)
return c.json({ success: true })
})
// List files
app.get('/files', async (c) => {
const prefix = c.req.query('prefix') || ''
const list = await c.env.BUCKET.list({ prefix, limit: 100 })
return c.json({
objects: list.objects.map(obj => ({
key: obj.key,
size: obj.size,
uploaded: obj.uploaded
}))
})
})
```
## Durable Objects
### Define Durable Object
```typescript
// src/counter.ts
export class Counter {
private state: DurableObjectState
private value: number = 0
constructor(state: DurableObjectState) {
this.state = state
}
async fetch(request: Request): Promise<Response> {
const url = new URL(request.url)
// Load value from storage
this.value = await this.state.storage.get('value') || 0
switch (url.pathname) {
case '/increment':
this.valuRelated in Cloud & DevOps
appbuilder-action-scaffolder
IncludedCreate, implement, deploy, and debug Adobe Runtime actions with consistent layout, validation, and error handling. Use this skill whenever the user needs to add actions to an App Builder project, understand action structure (params, response format, web/raw actions), configure actions in the manifest, use App Builder SDKs (State, Files, Events, database), deploy and invoke actions via CLI, debug action issues, or implement patterns such as webhook receivers, custom event providers, journaling consumers, large payload redirects, action sequence pipelines, and Asset Compute workers. Also trigger when users mention serverless functions in Adobe context, action logging, IMS authentication for actions, or cron-style scheduled actions.
orchestrating-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. Use this skill when the user needs a multi-step Data Cloud pipeline, cross-phase troubleshooting, or data space and data kit management. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase sf data360 workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching phase-specific skill), the task is STDM/session tracing/parquet telemetry (use observing-agentforce), standard CRM SOQL (use querying-soql), or Apex implementation (use generating-apex).
github-project-automation
IncludedAutomate GitHub repository setup with CI/CD workflows, issue templates, Dependabot, and CodeQL security scanning. Includes 12 production-tested workflows and prevents 18 errors: YAML syntax, action pinning, and configuration. Use when: setting up GitHub Actions CI/CD, creating issue/PR templates, enabling Dependabot or CodeQL scanning, deploying to Cloudflare Workers, implementing matrix testing, or troubleshooting YAML indentation, action version pinning, secrets syntax, runner versions, or CodeQL configuration. Keywords: github actions, github workflow, ci/cd, issue templates, pull request templates, dependabot, codeql, security scanning, yaml syntax, github automation, repository setup, workflow templates, github actions matrix, secrets management, branch protection, codeowners, github projects, continuous integration, continuous deployment, workflow syntax error, action version pinning, runner version, github context, yaml indentation error
sf-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase `sf data360` workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching sf-datacloud-* skill), the task is STDM/session tracing/parquet telemetry (use sf-ai-agentforce-observability), standard CRM SOQL (use sf-soql), or Apex implementation (use sf-apex).
fabric-cli
IncludedUse this skill for Fabric.so CLI workflows with the `fabric` terminal command: diagnose/install/login, search or browse a Fabric library, save notes/links/files, create folders, ask the Fabric AI assistant, manage tasks/workspaces, generate shell completion, check subscription usage, produce JSON output, and use Fabric as persistent agent memory. Do not use for Microsoft Fabric/Azure/Power BI `fab`, Daniel Miessler's Fabric framework, Python Fabric SSH, Fabric.js, or textile/fashion fabric.
lark
IncludedLark/Feishu CLI skills: lark-cli operations for docs, markdown, sheets, base, calendar, im, mail, task, okr, drive, wiki, slides, whiteboard, apps, approval, attendance, contact, vc, minutes, event. Use when the user needs to operate Lark/Feishu resources via lark-cli, send messages, manage documents, spreadsheets, calendars, tasks, OKRs, deploy web pages, or any Feishu/Lark workspace operations.