Overview
This guide helps you migrate your Hono applications between major versions. Follow the instructions for your specific version upgrade.v4.3.11 to v4.4.0
deno.land/x to JSR
There is no breaking change, but we no longer publish the module fromdeno.land/x. If you want to use Hono on Deno, use JSR instead.
Migration:
v3.12.x to v4.0.0
There are several breaking changes in v4.0.0.Removal of Deprecated Features
The following features have been removed:AWS Lambda Adapter
Next.js Adapter
Context Methods
Hono Methods
HonoRequest Methods
serveStatic Requires manifest
For Cloudflare Workers, specify themanifest option:
Other Changes
- JSX Renderer:
docTypeoption now defaults totrue - JSX FC: Use
PropsWithChildreninstead of passingchildrentoFC - Mime Types: Some mime types have been removed
- Type Changes: Improved types for middleware chaining and validation
v2.7.8 to v3.0.0
c.req is now HonoRequest
c.req is now a HonoRequest object instead of Request. Access the raw Request via c.req.raw:
StaticRouter is Obsolete
TheStaticRouter has been removed. Use the default router instead.
Validator Changes
The validator API has changed:serveStatic from Adapters
serveStatic is now provided by adapters:
Service Worker Mode Deprecated
For Cloudflare Workers, use Module Worker mode instead:Use type for Generics
Always usetype instead of interface for generics:
v2.2.5 to v2.3.0
Auth Middleware Changes
If using Basic Auth or Bearer Auth in a handler, change:v2.0.9 to v2.1.0
parseBody Changes
c.req.parseBody() now only parses FormData:
Generics Arguments Changed
The constructor now usesVariables and Bindings:
v1.6.4 to v2.0.0
Deno Middleware Import
Don’t import middleware fromhono/mod.ts:
Cookie Middleware Removed
Cookie functions are now built-in:Body Parse Middleware Removed
Usec.req.parseBody() instead:
GraphQL and Mustache Removed
GraphQL Server and Mustache middleware have been removed. Use third-party alternatives.Best Practices
Test before upgrading
Test before upgrading
Always test your application thoroughly after upgrading to a new major version.
Read the full changelog
Read the full changelog
Check the official changelog for additional changes and improvements.
Update dependencies
Update dependencies
Update related packages like validators and middleware along with Hono.
Upgrade incrementally
Upgrade incrementally
If jumping multiple versions, upgrade one major version at a time.
Related
- TypeScript - Update your types after migration
- Validation - Check validator changes
- Error Handling - Review error handling updates