hono-d1-integration

Implement Cloudflare D1 bindings, migrations, and service layers in Hono TypeScript apps.

2|Updated Dec 5, 2025
One-click install
npx skills add https://github.com/AgentiveCity/SkillFactory --skill hono-d1-integration
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hono-d1-integration
Source: https://github.com/AgentiveCity/SkillFactory/tree/main/.claude/skills/hono-d1-integration
Command: npx skills add https://github.com/AgentiveCity/SkillFactory --skill hono-d1-integration

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Designing, setting up, or refactoring Cloudflare D1 database usage in Hono + TypeScript apps running on Cloudflare Workers/Pages involves schema management, bindings, query patterns, and data-access structure. This can be intricate and error-prone. This Skill streamlines the integration, ensuring type-safe, runtime-safe, and structured D1 usage.

Core Features & Use Cases

  • Automated D1 Binding & Typing: Wire D1 bindings into Hono apps (c.env.DB) and ensure type-safe access via a shared Env interface.
  • Schema & Migration Management: Design D1 schemas and manage migrations via Wrangler, keeping SQL in version control and ensuring append-only changes.
  • Structured Data Access: Implement query helpers and service-level access patterns, encouraging parameterized queries and encapsulating DB logic.

Quick Start

Use Cloudflare D1 for persistence in this Hono API, create D1 schema and wire up user routes in Hono, and refactor my raw D1 queries into a service layer.

Frequently Asked Questions about hono-d1-integration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I integrate Cloudflare D1 with a Hono TypeScript application?

Integrate Cloudflare D1 by binding it to your Hono app via c.env.DB, defining a typed Env interface, and wiring the binding in wrangler.toml. This establishes type-safe database access across your Workers or Pages project.

What's the best way to manage database migrations with Cloudflare D1?

Use Wrangler-based migrations to manage D1 schema changes. Store SQL migration files in version control under a db/ directory, applying them sequentially to ensure append-only, reversible changes across local, development, and production environments.

Can I use parameterized queries with Cloudflare D1 in Hono?

Yes. Parameterized queries are enforced through D1's query helpers and a centralized data-access layer. Structure queries in service or repository classes to prevent SQL injection and ensure type safety across your application.

How do I structure database access in a Hono app using D1?

Implement a service or repository layer under a services/ directory that encapsulates all D1 queries. This centralizes database logic, enforces parameterized queries, and separates data-access concerns from route handlers.

Does Cloudflare D1 work in local development and testing environments?

Yes. D1 supports local, development, and testing environments through Wrangler configuration. Use separate bindings and migration strategies per environment to test your schema and queries before deploying to production.

What type of project structure should I use for D1 with Hono and TypeScript?

Follow a conventional layout with db/ for migrations and schemas, services/ for data-access logic, and typed environment bindings via a shared Env interface. This organization keeps database concerns isolated and maintainable as your app scales.