Migrating from Hono
Hono and Shokupan share many modern design philosophies (Web Standards, TypeScript first), so migration is typically converting syntax rather than logic.
Key Differences
Section titled “Key Differences”- Context Name: Hono uses
cby convention; Shokupan usesctx. You can usecif you prefer. - Chaining: Hono apps often chain methods (
app.get().post()); Shokupan recommends separate statements (app.get(); app.post()) though you can chain if you prefer. - Middleware: Both use
await next()for async middleware patterns.
Basic Server
Section titled “Basic Server”Hono:
import { Hono } from 'hono';const app = new Hono();
app.get('/', (c) => c.text('Hello Hono!'));
export default app;Shokupan:
import { Shokupan } from 'shokupan';const app = new Shokupan();
app.get('/', (ctx) => { return ctx.text('Hello Shokupan!');});
app.listen(3000);Middleware
Section titled “Middleware”Both frameworks use similar middleware patterns.
Hono:
app.use(async (c, next) => { const start = Date.now();
await next();
const end = Date.now(); c.res.headers.set('X-Response-Time', `${end - start}ms`);});Shokupan:
app.use(async (ctx, next) => { const start = Date.now();
await next();
const end = Date.now(); ctx.response.headers.set('X-Response-Time', `${end - start}ms`);});Validation
Section titled “Validation”Hono uses zod-validator middleware. Shokupan supports Zod validation with the Validation plugin.
Shokupan Validation:
import { Validation } from 'shokupan';import { z } from 'zod';
const schema = z.object({ name: z.string()});
app.post('/user', Validation(schema), (ctx) => { const data = ctx.body; // Typed automatically! return { created: data.name };});Next Steps
Section titled “Next Steps”- Routing - Routing guide
- Validation - Input validation