nextjs app router `fetchRequestHandler`'s createContext doesn't run.
Hey there,
I have the following code:
13 Replies
When i invoke any trpc endpoint with an http request, the request goes through, but the context does not run.
I'm pretty sure the
createTRPCContext
should be invoked on every request/batch of requestsare you passing createContext to fetchRequestHandler
ah nvm it’s in the post body
this is definitely a bug
can you create an issue with a minimal reproduction?
I'll try to
Hey @sachinraja sorry for the ping, however, do you guys have an example tRPC with react 13 app router ?
GitHub
trpc/examples/.experimental/next-app-dir at main · trpc/trpc
🧙♀️ Move Fast and Break Nothing. End-to-end typesafe APIs made easy. - trpc/trpc
Last question: Are you sure what i sent above is a bug?
Should the
createContext
run on every single request made to trpc ?yes
What if it's used with
appRouter.createCaller
?yes but you have to pass createContext to that too
Well there were some example with
appRouter.createCaller(await createContext())
But as we know, this means top level await... which is not supported afaik.you shouldnt be calling createCaller at the top level
Do you have an example/snippet you could link me to see?
what are you using it for
Well nothing so far. I'm very new to react space and i've been meaning to setup myself a nextjs app router project template to use
I'm trying to understand how the whole structure maps out and works under the hood.