T
tRPC

❓-help

How can I access ctx from inside of a procedure?

Ssb4/4/2023
const appRouter = t.router({
helloTab: t.procedure.input(z.object({ url: z.string().url() })).mutation(async ({ input, ctx }) => {
//@ts-ignore
const tab = ctx.sender.tab
console.log(tab)
}),
});
const appRouter = t.router({
helloTab: t.procedure.input(z.object({ url: z.string().url() })).mutation(async ({ input, ctx }) => {
//@ts-ignore
const tab = ctx.sender.tab
console.log(tab)
}),
});
is something like this possible? Not working for me
Nnlucas4/5/2023
That’s how it works yes, did you forget to set the type in initTRPC?

Looking for more? Join the community!