feat: remove 'db' from the tRPC 'ctx' for a massive typescript speed increase

Author: anthnykrCreated Aug 26, 2025Updated Feb 23, 2026
Labels🌟 enhancement

Is your feature request related to a problem? Please describe.

I've worked with tRPC in large production codebases - having the db returned here in src/server/api/trpc slows down the typescript server massively.

bash
export const createTRPCContext = async (opts: { headers: Headers }) => {
  const session = await auth();

  return {
    db,
    session,
    ...opts,
  };
}

Describe the solution you'd like to see

Remove db from the return and import db in tRPC routes instead. For example, await db.user.findUnique instead of await ctx.db.user.findUnique. This speeds it up significantly.

Describe alternate solutions

N/A

Additional information

No response