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
@trpc/next
ssr mode now requires a prepass helper with ssr: true
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
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.
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});
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 (breaking)
We have refactored our internal generics and made them more readable (TODO: link procedure builder sauce)
React is now >=18.2.0 (breaking)
Check their migration guide: https://react.dev/blog/2022/03/08/react-18-upgrade-guide
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
(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 (non-breaking for most)
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
.unstable_concat()
removed
To our knowledge, this was never used by anyone. If you need it, please open an issue on GitHub.
We might add it back in the future if there is a need for it.
interop
-mode has been removed
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.