How to use `localLink` (`unstable_localLink`)
This is more of a guide, rather than a question since I've found no docs on how to use this function to fix SSR related issues.
So, based on https://orpc.unnoq.com/docs/best-practices/optimize-ssr I've managed to cook something that has fixed my issues with the headers not passed to the requests on initial SSR of "use client" components (nextjs).
So, in my
In
and also:
I also had to add imports to
Question:
Is this is safe to do on the server side? (As in, does
So, based on https://orpc.unnoq.com/docs/best-practices/optimize-ssr I've managed to cook something that has fixed my issues with the headers not passed to the requests on initial SSR of "use client" components (nextjs).
So, in my
trpc/server/index.ts (usually server.ts) I added the following:In
trpc/client.ts:and also:
I also had to add imports to
instrumentation.ts (See the orpc docs), and to my very root layout (Just make sure it's not use client!)Question:
Is this is safe to do on the server side? (As in, does
localLink do any kind of caching or something that could leak data between users?)Optimize SSR performance in Next.js, SvelteKit, and other frameworks by using oRPC to make direct server-side API calls, avoiding unnecessary network requests.
