tRPCttRPC
Powered by
craftzcodeC
tRPC•11mo ago
craftzcode

Troubleshooting createTRPCOptionsProxy with Server Components and Context Passing

How does
createTRPCOptionsProxy
createTRPCOptionsProxy
work in server components?

I'm creating a context that passes the
hono
hono
context to
createTRPCContext
createTRPCContext
in order to obtain the
HTTP headers
HTTP headers
, since I need to forward those
headers
headers
to the
better-auth API
better-auth API
to get the
session
session
I use
@hono/trpc-server
@hono/trpc-server
which created by the
hono
hono
so I can use
hono
hono
as adapter of
trpc
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.
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
createTRPCContext
properly?
image.png
image.png
image.png
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

createTRPCOptionsProxy needs a queryClient?
AleksanderAAleksander / ❓-help
4mo ago
Using react server components with separate API
ArxkAArxk / ❓-help
3mo ago
Context and TanStack
coder2000Ccoder2000 / ❓-help
10mo ago