🚨 Breaking Changes Alert 🚨
We've revamped the Fetch handler APIs for a cleaner, more modular experience. Here's what you need to know:
What's Changed?
The new API lets you define handlers inline without global declarations. This simplifies your setup and keeps your bundle lightweight—especially useful for serverless environments.
import { createOpenAPIServerlessHandler } from '@orpc/openapi/fetch';
import { createORPCHandler, handleFetchRequest } from '@orpc/server/fetch';
export function fetch(request: Request) {
return handleFetchRequest({
router,
request,
prefix: '/api',
context: {},
handlers: [
createORPCHandler(),
createOpenAPIServerlessHandler(), // Or use createOpenAPIServerHandler
],
});
}
Key Benefits:
- No Global Handler Declaration: Handlers are now scoped to the function where they're used.
- Smaller Serverless Bundles: Bundle only the handlers you need for your use case.
- Future-Ready: This lays the groundwork for upcoming big features (stay tuned!). 🚀
If you're upgrading, make sure to update your fetch
handlers to use this new API format.