Examples
Starter examples for different runtimes and storage drivers
Starter Examples
Ready-to-use examples demonstrating hono-universal-cache with different runtimes and storage backends.
Node.js + Redis
Full-featured example using Node.js with Redis storage.
Features:
- Express-style Node.js server with
@hono/node-server - Redis cache storage with
ioredis - Docker Compose setup for Redis
- Environment variable configuration
- Multiple cached and non-cached routes
Location: examples/nodejs-redis
Quick Start:
cd examples/nodejs-redis
pnpm install
docker-compose up -d
cp .env.example .env
pnpm devTest the cache:
# First request - cache miss
curl http://localhost:3000/time
# Second request - cache hit (same response for 60s)
curl http://localhost:3000/timeBun + Redis (Custom Driver)
Example using Bun's native Redis client with a custom unstorage driver.
Features:
- Bun runtime with native
.envsupport - Custom Redis storage driver using Bun's
RedisClient - No ioredis dependency - uses Bun's native Redis
- Docker Compose setup
- Demonstrates custom driver implementation
Location: examples/bun-redis-custom-driver
Quick Start:
cd examples/bun-redis-custom-driver
bun install
docker-compose up -d
cp .env.example .env
bun devCustom Driver:
The example includes a complete custom storage driver implementation at src/custom-driver-redis.ts showing how to create your own unstorage driver using Bun's native APIs.
Next.js + Vercel KV
Next.js App Router example with Vercel KV storage and Hono API routes.
Features:
- Next.js 16 with App Router
- Hono API routes under
/honobase path - Vercel KV storage for caching
- Local development with
serverless-redis-http - Production-ready for Vercel deployment
Location: examples/nextjs-vercel-kv
Quick Start:
cd examples/nextjs-vercel-kv
pnpm install
docker-compose up -d # For local development
cp .env.example .env.local
pnpm devAPI Routes:
GET /hono/time- Cached server time (60s TTL)
Example Structure
Each example includes:
README.md- Detailed setup and usage instructions.env.example- Environment variable templatedocker-compose.yaml- Local development services (where applicable)package.json- Dependencies and scripts- Source code - Complete working implementation
Running Examples
All examples are part of the monorepo and use pnpm workspaces:
# From repository root
pnpm install
# Run specific example
cd examples/[example-name]
pnpm devCreating Your Own
Use these examples as templates for your own projects:
- Choose the runtime that matches your deployment target
- Select a storage driver based on your infrastructure
- Copy the example and customize for your needs
- Configure environment variables for your setup
- Deploy to your platform of choice
Need Help?
- Check the example's
README.mdfor detailed instructions - Review the API Reference for configuration options
- Explore Storage Drivers for more backends
- See Use Cases for common patterns