craftzcodeC
tRPC10mo ago
craftzcode

Troubleshooting createTRPCOptionsProxy with Server Components and Context Passing

How does createTRPCOptionsProxy work in server components?

I'm creating a context that passes the
hono
context to createTRPCContext in order to obtain the HTTP headers, since I need to forward those headers to the better-auth API to get the session I use @hono/trpc-server which created by the
hono
so I can use
hono
as adapter of
trpc
.

Type '(c: HonoContext) => Promise<{ session: { session: { id: string; createdAt: Date; updatedAt: Date; userId: string; expiresAt: Date; token: string; ipAddress?: string | null | undefined | undefined; userAgent?: string | null | undefined | undefined; }; user: { ...; }; } | null; }>' is not assignable to type '{ session: { session: { id: string; createdAt: Date; updatedAt: Date; userId: string; expiresAt: Date; token: string; ipAddress?: string | null | undefined; userAgent?: string | null | undefined; }; user: { ...; }; } | null; } | (() => MaybePromise<...>)'.
  Type '(c: HonoContext) => Promise<{ session: { session: { id: string; createdAt: Date; updatedAt: Date; userId: string; expiresAt: Date; token: string; ipAddress?: string | null | undefined | undefined; userAgent?: string | null | undefined | undefined; }; user: { ...; }; } | null; }>' is not assignable to type '() => MaybePromise<{ session: { session: { id: string; createdAt: Date; updatedAt: Date; userId: string; expiresAt: Date; token: string; ipAddress?: string | null | undefined; userAgent?: string | ... 1 more ... | undefined; }; user: { ...; }; } | null; }>'.
    Target signature provides too few arguments. Expected 1 or more, but got 0.


Is there any solution to this issue so that I can pass my createTRPCContext properly?
image.png
image.png
image.png
Was this page helpful?