Adapter architecture
One of the core designs of VextJS is the Adapter architecture - the underlying HTTP processing layer is completely replaceable. Your business code (routing, middleware, services, plug-ins) operates on the req / res objects encapsulated by VextJS, rather than the native objects of the underlying framework. Switching the Adapter only requires modifying one line of configuration, with zero changes to the business code.
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
Historical benchmark snapshot (JSON response scenario, median of 5 rounds):
Vext overhead includes: body parser, response wrapper, request/response abstraction, AsyncLocalStorage context, middleware chain executor, etc. complete functions.
Test environment: Node.js v24.14.0 / Windows x64 / Intel i7-9700 / autocannon (50 connections, 10 pipelining, 10s × 5 rounds median, 2026-03-23). The actual reproduction test of the current version is subject to the benchmark in the warehouse, and distinguishes between
chainandmiddleware-chain.
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:
Native Adapter uses Node.js native http.createServer to process HTTP, and cooperates with route-core for route matching, with optimal performance and zero dependence on external HTTP frameworks.
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), suitable for full-stack applications and edge runtimes (such as Cloudflare Workers).
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:
**No changes are required to the business code. ** Route definition, middleware, service layer, plug-in - all user code operates on the VextRequest / VextResponse interface and is completely decoupled from the underlying framework.
How to choose Adapter
Select Native (recommended by default)
- Pursue maximum performance
- An ecosystem that does not rely on other frameworks
- New project, no historical baggage
- Hope zero extra dependencies
Select Hono
- Requires middleware or tools from the Hono ecosystem
- Planned future deployment to edge runtimes (Cloudflare Workers, etc.)
- 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:
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)
VextResponse (unified response object)
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?
The performance difference mainly comes from the HTTP parsing, route matching and serialization efficiency of the underlying framework itself. The overhead of the VextJS layer (middleware chain, request/response packaging, etc.) is basically the same across all Adapters. Native Adapter has the highest performance because it uses the lowest level http.createServer, eliminating the need for additional abstractions at the framework layer.
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, when using the Hono Adapter, only hono and @hono/node-server are installed, and peer dependency warnings from other frameworks can be safely ignored.
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