Adapter architecture
VextJS uses an adapter architecture so the underlying HTTP layer can be replaced. Application routes, middleware, services, and plugins use VextJS req / res objects instead of the underlying framework's native objects. In the supported abstraction, switching adapters is a configuration change rather than a rewrite of route handlers.
Working principle
Adapter is responsible for:
- Start HTTP service — Use the underlying framework to create a server and listen on the port
- Request Conversion — Convert the native request object of the underlying framework into
VextRequest - Response conversion — Map the operations of
VextResponseto the response object of the underlying framework - Route Registration — Register the routes collected by the framework to the underlying routing system
- Middleware Registration — Register global middleware to the underlying framework
Built-in Adapter
VextJS has 5 built-in Adapters, covering the mainstream Node.js HTTP framework:
Performance comparison
This page does not keep a separate numeric snapshot, because an old environment would create a second, conflicting source of truth. Raw Native and Raw Fastify trade the lead as scenarios and handler shapes change. The five-adapter percentages measure Vext against each adapter's own Raw baseline; they are not an overall framework ranking.
Use the Performance benchmarks page for the current results, methodology, limitations, and reproduction commands. After choosing an adapter, validate it with your real middleware, authentication, logging, and I/O workload.
How to use
Native Adapter (default)
No additional dependencies need to be installed, and no explicit configuration is required - the default is Native Adapter:
For explicit declaration:
The Native adapter uses Node.js http.createServer with route-core. It is the default path and has no third-party HTTP framework dependency. Performance varies by workload, so use the current benchmark and your application tests when making a decision.
Hono Adapter
Recommended method (string identification):
Advanced usage (factory function):
Hono is an ultra-lightweight web framework based on the Web Standards API (Request / Response). The current built-in Hono Adapter is a Node.js HTTP server adapter. It depends only on hono; Vext owns the node:http request/response bridge used to expose Hono routing inside a Node.js service. @hono/node-server is not a runtime dependency of this adapter.
This does not represent official Edge / Serverless adapter support. Cloudflare Workers, Deno Deploy, Bun edge, and other non-Node.js runtimes require a dedicated Edge / Serverless adapter or ecosystem plugin. Do not treat the current vextjs/adapters/hono package as an Edge runtime guarantee.
Fastify Adapter
Recommended method (string identification):
Advanced usage (factory function, options can be passed in):
Fastify is a high-performance Node.js web framework with a rich plug-in ecosystem and built-in JSON Schema verification + serialization optimization.
Express Adapter
Recommended method (string identification):
Advanced usage (factory function, options can be passed in):
Express is the most mature web framework in the Node.js ecosystem and has the largest middleware ecosystem. VextJS supports Express v5. Suitable for migrating from existing Express projects.
VextJS's Express Adapter is based on Express v5. If you are using Express v4, you need to upgrade first. Compared with v4, the main changes in v5 include: routing processing supports async/await, improved req.query parsing, etc.
Koa Adapter
Recommended method (string identification):
Advanced usage (factory function, options can be passed in):
Koa is a next-generation web framework built by the Express team and is known for its lightweight and elegance. VextJS supports Koa v3.
Switch Adapter
To switch Adapter, you only need to modify the adapter field in src/config/default.ts:
Route handlers and services built on VextRequest / VextResponse can usually be reused. Native middleware, plugins, and framework-specific behavior are not fully decoupled, so review the target adapter's integration boundary before switching.
How to choose Adapter
Select Native (recommended by default)
- Start with the framework's default path
- Do not require capabilities from another HTTP framework
- Build a new project without adapter migration constraints
- Keep additional dependencies to a minimum
Select Hono
- Requires middleware or tools from the Hono ecosystem
- Want Hono routing inside a Node.js service; future Edge / Serverless deployment requires a dedicated adapter
- Prefer Web Standards API style
Select Fastify
- Requires use of Fastify’s rich plug-in ecosystem
- Large projects that value Fastify’s maturity and community support
- Requires
fast-json-stringifyserialization optimization
Select Express
- Migrate existing Express projects to VextJS
- Need to reuse a lot of Express middleware
- The team is most familiar with Express
Select Koa
- Prefer Koa's lightweight design
- Small and medium-sized projects
- Requires Koa specific middleware
VextAdapter interface
All Adapters implement the unified VextAdapter interface:
OpenAPI / Docs routes are registered by the framework through registerRoute(). Adapters no longer expose a separate registerOpenAPIRoutes() method.
Custom Adapter
If the five built-in Adapters cannot meet your needs, you can implement a custom Adapter:
When implementing a custom Adapter, the core work is to perform bidirectional conversion between VextRequest / VextResponse and the native objects of the underlying framework, and correctly execute the middleware chain.
Request/response conversion
Regardless of which Adapter is used, user code always operates on the unified VextRequest and VextResponse interfaces.
VextRequest (unified request object)
_getRawBody() / _getRawBodyBuffer() are injected by adapters and primarily used by framework middleware and plugins such as multipart parsers. Application handlers should usually use req.body, req.files, and req.valid().
VextResponse (unified response object)
stream() / download() accept Node.js Readable / NodeJS.ReadableStream, not Web ReadableStream. rawJson() and underscore-prefixed response methods are framework internals; application code should use the public methods visible through VextPublicResponse.
This design means:
- Switching Adapter does not affect any business code
- Middleware behaves consistently across all Adapters
- Test code has nothing to do with Adapter
Switch Adapter according to environment
You can use different Adapters in different environments:
FAQ
Do I need to modify the code after switching the Adapter?
unnecessary. All business code (routing, middleware, services, plug-ins) operates the VextRequest / VextResponse interface and is completely decoupled from the underlying Adapter.
Can Adapter be switched dynamically at runtime?
Can't. Adapter is determined by configuration at startup and cannot be switched during runtime. If you need to use different Adapters depending on the environment, please use the configuration file override mechanism (such as development.ts / production.ts).
Where does the performance difference mainly come from?
Performance differences come from both the underlying framework's HTTP parsing, routing, and serialization and Vext's integration path for each adapter. Current measurements show different overhead against each Raw baseline, with no implementation leading every scenario. Review the Performance benchmarks methodology, then test your actual middleware and I/O workload.
Can the native middleware of the underlying framework be used?
Not recommended for direct use. VextJS has its own middleware system (defineMiddleware / defineMiddlewareFactory). The native middleware signature of the underlying framework is different and cannot be directly compatible. If you need to use the middleware function of an underlying framework, it is recommended to encapsulate it as VextJS middleware or plug-in.
What should I do if peer dependencies report a warning?
VextJS declares all underlying frameworks as optional peerDependencies. You only need to install the framework package corresponding to the Adapter you actually use. For example, the Hono Adapter requires only hono; peer dependency warnings from other unused frameworks can be safely ignored.
The current Hono Adapter is a Node.js runtime capability: it receives requests through a Node.js HTTP server and bridges them into Hono's Web Request / Response flow. Edge / Serverless runtimes should not use these Node adapter installation instructions as a support claim.
Next step
- Understand the Adapter-related configuration items in Configuration
- View the performance of OpenAPI Documentation under different Adapters
- Explore the cooperation between Cluster multi-process and Adapter
- Read benchmark data related to Performance Benchmark