Hi! I’m a big fan of tRPC! I’ve been using it for quite some time.
I actually have 2 questions:
2) Can we use the Next.js cachecache and revalidaterevalidate fetch options with tRPC on a request level?
Since Next.js 13, we have been able to set the cache behavior on a per-request basis. But for that we need to use the fetchfetch method. I think it would be great if we could set it while using a type-safe method with tRPC.
1) What would be a good way to create the caller in the App Router?
This is what I’m currently doing to create the caller to use in RSC.
I’m creating a fake Request instance with the real request headers, so that I can use the request to get the next-auth token and pass it to my tRPC context.
This feels a little hacky… Does someone knows a better way?
// server.tsexport async function createCaller() { return appRouter.createCaller( await createTRPCContext({ req: new NextRequest( new Request("http://dummy-url.com", { headers: headers(), }), ), }), );}
// server.tsexport async function createCaller() { return appRouter.createCaller( await createTRPCContext({ req: new NextRequest( new Request("http://dummy-url.com", { headers: headers(), }), ), }), );}