KINOK
tRPC2y ago
2 replies
KINO

How is inner context persistent if we call 'createContext' for every batch?

As per title. According to the docs, inner context doesn't depend on the request, and is useful for persistent objects like your database connection. However, given that
createContext
is called for every request, I fail to see how calling createInnerContext inside of
createContext
provides persistence?

Docs that I read: https://trpc.io/docs/server/context#inner-and-outer-context
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.
Context | tRPC
Was this page helpful?