bigshot824
bigshot8242d ago

NextJS trpc caller and Hono

Hi, do you manage to use appRouter.createCaller? I have nextjs and hono backend separate. I wanted to use caller in server components. I have this in my hono context and on my screenshot was the appRouterCaller. I'm having difficulty to access the context. Hope you can help.
import type { Context as HonoContext } from "hono"
import { auth } from "./auth"

export type CreateContextOptions = {
context: HonoContext
}

export async function createContext({ context }: CreateContextOptions) {
const session = await auth.api.getSession({
headers: context.req.raw.headers
})

return { session }
}
import type { Context as HonoContext } from "hono"
import { auth } from "./auth"

export type CreateContextOptions = {
context: HonoContext
}

export async function createContext({ context }: CreateContextOptions) {
const session = await auth.api.getSession({
headers: context.req.raw.headers
})

return { session }
}
1 Reply
bigshot824
bigshot824OP2d ago
This is how I call the appRouter.createCaller().
No description

Did you find this page helpful?