Migrate from v10 to v11
This is a current work in progress representing version 11.
- The functionality is stable and can be used in production, but we may do small breaking API-changes between patches until we reach
11.0.0
- The packages are published with the
next
-tag on npm
Installation / upgrading
- npm
- yarn
- pnpm
- bun
npm install @trpc/server@next @trpc/client@next @trpc/react-query@next @trpc/next@next @tanstack/react-query@latest @tanstack/react-query-devtools@latest
yarn add @trpc/server@next @trpc/client@next @trpc/react-query@next @trpc/next@next @tanstack/react-query@latest @tanstack/react-query-devtools@latest
pnpm add @trpc/server@next @trpc/client@next @trpc/react-query@next @trpc/next@next @tanstack/react-query@latest @tanstack/react-query-devtools@latest
bun add @trpc/server@next @trpc/client@next @trpc/react-query@next @trpc/next@next @tanstack/react-query@latest @tanstack/react-query-devtools@latest
Reverse-chronological changelog
This is a draft document. It will be updated to a proper guide as we get closer to the v11 release. The only major thing that will incur work for you is that you will need to do is to update TanStack Query to v5.0.0.
Support for streaming responses over HTTP
We now support streaming mutations and queries using the httpBatchStreamLink
.
This means that query and mutation resolvers can either be AsyncGenerator
s with yield
or return promises that can be deferred for later and you can use stream responses over HTTP, without using WebSockets.
We want your feedback on this feature, so please try it out and let us know what you think in the 🎏-rfc-streaming
-channel on our Discord!
👉 See more in the httpBatchStreamLink
docs
resolveHTTPRequest
has been replaced by resolveRequest
that uses Fetch APIs (rarely breaking)
The function resolveHTTPRequest
has been replaced by resolveRequest
which uses the Fetch API - Request
/Response
.
This is a breaking change for HTTP-adapters, but should not affect you as a user.
If you're building an adapter, check out how our adapters work in the code and don't be a stranger to ask for help in our Discord.
TRPCRequestInfo
has been updated (rarely breaking)
Inputs are now materialised lazily when required by the procedure, which means the input and procedure type is no longer available when tRPC calls createContext
.
You can still access the input by calling info.calls[index].getRawInput()
.
All the experimental form-data support has been replaced (rarely breaking)
This only affects you if you used the experimental formdata features
- experimental_formDataLink - use httpLink
- experimental_parseMultipartFormData - not needed anymore
- experimental_isMultipartFormDataRequest - not needed anymore
- experimental_composeUploadHandlers - not needed anymore
- experimental_createMemoryUploadHandler - not needed anymore
- experimental_NodeOnDiskFile and experimental_createFileUploadHandler - not supported in this first release, open an issue if you need to hold data on disk
- experimental_contentTypeHandlers - not needed anymore, but could come back if needed by the community for novel data types
You can see the new approach in examples/next-formdata
Moved Procedure._def._output_in
/ Procedure._def._input_in
to Procedure._def.$types
(non-breaking)
This is a breaking change for tRPC internals, but should not affect you as a user.
You don't have to do anything, unless you're using Procedure._def._output_in
or Procedure._def._input_in
directly in your code.
Explicit Content-Type checks (non-breaking)
We now have explicit checks for the Content-Type
-header when doing POST-requests. This means that if you send a request with a Content-Type
that doesn't match the expected one, you will get a 415 Unsupported Media Type
-error.
Our tRPC clients already sends content-type headers, so is only a potential breaking change if you call tRPC manually.
Added support for method overriding (rarely breaking)
Allows you to override the HTTP method for procedures to always be sent with POST
in order to get around some limitations with e.g. max URL lengths.
Closes #3910
Added support for bi-directional infinite queries (non-breaking)
Added inferProcedureBuilderResolverOptions<T>
-helper (non-breaking)
Adds a helper to infer the options for a procedure builder resolver. This is useful if you want to create reusable functions for different procedures.
See test here for a reference on how to use it
Transformers are moved to links (breaking)
TypeScript will guide you through this migration
Only applies if you use data transformers.
You now setup data transformers in the links
-array instead of when you initialize the tRPC-client;
Wherever you have a HTTP Link you have to add transformer: superjson
if you use transformers:
ts
httpBatchLink({url: '/api/trpc',transformer: superjson, // <-- add this});
ts
httpBatchLink({url: '/api/trpc',transformer: superjson, // <-- add this});
ts
createTRPCNext<AppRouter>({// [..]transformer: superjson, // <-- add this});
ts
createTRPCNext<AppRouter>({// [..]transformer: superjson, // <-- add this});
@trpc/next
ssr mode now requires a prepass helper with ssr: true
(rarely breaking)
This is to fix https://github.com/trpc/trpc/issues/5378 where react-dom
was imported regardless if you were using this functionality or not.
See SSR docs
Added support for short-hand router definitions (non-breaking)
See Merging routers
ts
const appRouter = router({// Shorthand plain object for creating a sub-routernested1: {proc: publicProcedure.query(() => '...'),},// Equivalent of:nested2: router({proc: publicProcedure.query(() => '...'),}),});
ts
const appRouter = router({// Shorthand plain object for creating a sub-routernested1: {proc: publicProcedure.query(() => '...'),},// Equivalent of:nested2: router({proc: publicProcedure.query(() => '...'),}),});
Deleted inferHandlerInput<T>
and ProcedureArgs<T>
(non-breaking for most)
If these types mean nothing for you or your codebase, just ignore this
Use inferProcedureInput<TProcedure>
instead & TRPCProcedureOptions
instead
Added useSuspenseQueries()
https://github.com/trpc/trpc/pull/5226
Refactor internal generics (rarely breaking)
We have refactored our internal generics and made them more readable (TODO: link procedure builder sauce)
React is now >=18.2.0 (rarely breaking)
Check their migration guide: https://react.dev/blog/2022/03/08/react-18-upgrade-guide
NodeJS 18+ and Modern Browsers are now required (rarely breaking)
We have added usage of FormData, File, Blob, and ReadableStream. NodeJS 18 is now required, though these have been supported by browsers for many years now.
wsLink
improvements (minor)
- Ability to pass a
Promise
in theurl
-callback if servers switch location during deploys - Added new
lazy
option that makes the websocket automatically disconnect when there are no pending requests
rawInput
in middleware is now a getRawInput
(rarely breaking)
While we're not doing anything differently internally (just yet) this is help support a much requested feature in tRPC: content types other than JSON.
Simplified types and .d.ts
outputs
Procedures in your router now only emit their input & output - where before they would also contain the full context object for every procedure, leading to unnecessary complexity in e.g. .d.ts
.
React Query peerDep is now v5 (breaking)
Check their migration guide: https://tanstack.com/query/v5/docs/framework/react/guides/migrating-to-v5
Exports names AbcProxyXyz
has been renamed to AbcXyz
(non-breaking)
The proxy names were due to v9 using the AbcXyz
names, these have been removed and the proxy ones have been renamed to the non-proxy names, e.g:
createTRPCClient
was deprecated from v9, and is now completely removed. ThecreateTRPCProxyClient
has been renamed tocreateTRPCClient
instead.createTRPCProxyClient
is now marked as deprecated.
SSG Helpers (rarely breaking)
createSSGHelpers
were for v9 which has now been removed. the v10 equivalentcreateProxySSGHelpers
have been renamed tocreateSSGHelpers
now instead.createProxySSGHelpers
is now deprecated but aliased tocreateSSGHelpers
for backwards compatibility.- Removed exported type
CreateSSGHelpersOptions
interop
-mode has been removed (rarely breaking)
We have removed the interop
-mode from tRPC. This was a mode that allowed you to have an easy transition period from v9 to v10. This mode was never meant to be supported long-term and we have now removed it.