Support for platform native Response class and breaking changes
Pre-release8.0.0-next.13 (2025-12-02)
Breaking Changes
Renamed Request and Response classes
Migration required: The Request and Response classes have been renamed to HttpRequest and HttpResponse to avoid conflicts with platform-native global classes.
What you need to do:
Update your imports and type annotations:
// Before
import { Request, Response } from '@adonisjs/core/http'
// After
import { HttpRequest, HttpResponse } from '@adonisjs/core/http'Why this change? Modern JavaScript runtimes expose native Request and Response classes globally, which created naming conflicts and confusion. This rename provides better clarity and prevents ambiguity between AdonisJS classes and platform-native APIs.
New Features
Platform-native Response support
You can now return platform-native Response objects directly via the response.send() method. This enables seamless integration with libraries that return standard Response objects, such as Vercel's AI SDK.
import { streamText } from 'ai'
async handle({ response }: HttpContext) {
const result = await streamText({
model: openai('gpt-4'),
prompt: 'Write a story'
})
return result.toUIMessageStreamResponse()
}Custom response serializers
You can now define custom serializers to control how response data is serialized before being sent to the client. This is particularly useful for:
- Adding custom serialization logic for specific data types
- Implementing organization-wide response formatting standards
- Handling special object types
Configuration:
// config/app.ts
{
http: definedConfig({
serializeJSON: (value) => {
return JSON.stringify(value)
}
})
}Bug Fixes
- Ensure x-request-id header is always set on responses (#111) 5566086, closes #111
- pending references of Response class ab5694a
Commits
- add support for handling platform native Response and rename our classes d5d971a
- add support for using a custom JSON serializer for outgoing response aebbdc3
- migrate to cookie-es 30533b3
- throw proper error when url builder does not receive routes in correct shape d8d9efa
PRS
- Ensure x-request-id header is always set on responses by @ThisIsMissEm in #111
New Contributors
- @ThisIsMissEm made their first contribution in #111
Full Changelog: v8.0.0-next.12...v8.0.0-next.13