can't create context when using nextjs app dir
Im trying to use the latest version of nextjs and make use of the app directory. when trying to make a create context function like they show in the docs here: https://trpc.io/docs/server/context , it gives the following error when i try to create the handler on the frontend
I even try using
createNextApiHandler
which removes the error from here but causes issues when trying to create the trpc/server.ts file for the server components, particularly when trying to use the createCallerFactory
function (see second screenshot)
any help would be apprieciatedContext | tRPC
Your context holds data that all of your tRPC procedures will have access to, and is a great place to put things like database connections or authentication information.

4 Replies
second screenshot

did you solve this yet ?
Same issue any suggestions?
you should use
FetchCreateContextFnOptions
if you use an app/api/[trpc]/route.ts
(and not a pages/api/[trpc].ts
)
e.g.
please make a PR to the docs where it'd make it clearer for you