next()
: method in server-side middlewares - see docsresponseMeta()
: Better support for custom HTTP headers & status code - see caching docs- Server-side errors in
@trpc/next
are now serialized
Upgrade guide for the 99% usecase
npx npm-check-updates --filter /@trpc/ -u && yarn
- Simply update any
.middleware()
and addreturn next()
at the end. See middleware docs
Breaking changes
- Middlewares will now have to call a
next()
function that you have to call. - Reduce
TRPCError
s -METHOD_NOT_FOUND
removed &PATH_NOT_FOUND
renamed toNOT_FOUND
(#733) - Align input and output serialization (#746)
- Remove deprecated
httpErrors
-helper - Remove support for
?input
to be an array - now assuming aRecord<number, unknown>
-style dict (changed with backward compat in #669) - Remove support for
POST
calls being{ input: x }
(originally from #671) - Refactored some internals and removed some unnecessary exports on adapters - minor breaking changes if someone relied on something they shouldn't have :)
- Stricter
ErrorFormatter
-data
has to be aRecord<string, unknown>
Minor changes
- Expose
httpStatus
as part of error object as the default error shape httpStatus
will be used to determine the actual HTTP Status code set- Expose
TRPCClientError.data
as a shortcut toerror.shape.data
as that's the only one I find myself using TRPCError
we infer in@trpc/react
is nowTRPCErrorLike
and is serialized for SSR in@trpc/next
- add new method
responseMeta()
that is triggered before a request ends - both as part of@trpc/next
&@trpc/server
- on
@trpc/server
receivestype
,paths
,errors
, and the unserializeddata[]
that is going out - on
@trpc/next
it client errors
- on
Thanks to @mmkal, @peterp, @anthonyshort, & @simonedelmann for your feedback!