tRPCttRPC
Powered by
denik1981D
tRPC•3y ago•
1 reply
denik1981

When using createServerSideHelpers can the context be typed as GetServerSidePropsContext?

I assume the reason we should recreate the context when using createServerSideHelpers is because the req, res we get from GetServerSidePropsContext are not typed the same as the ones we get from NextApiRequest and NextApiResponse.

Fair enough. but can I create create my context based on the ctx we get from GetServerSidePropsContext?
If that the case is it a good approach to extend the InnerContext from the union of the both Partial contexts, and by "both" I mean the context we are expected to get and work with when calling our routers from the next API handler and from getServerSideProps?

Sorry if my question is not very clear and probably the answer won't be needed by me because I'm trying to not use getServerSideProps at all but still I would like to master my understanding of how TRPC serverSideHelpers are doing this in case I need them in the future.

The goal here will be to keep procedures that depend in certain values obtain from req or res being able to work dispite the source of the caller. So I would expect to regenerate the context for my instance of serverSideHelpers properly to make the request pass and being processed without troubles.

Thanks!
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Type of createServerSideHelpers?
nehalistNnehalist / ❓-help
3y ago
can't create context when using nextjs app dir
KyleBKKyleB / ❓-help
14mo ago
Can a URL be formatted with dashes, such as "user-list" in the context of trpc?
john99Jjohn99 / ❓-help
3y ago