tRPC SSG Helper w/ new Clerk middleware

So my goal is to do almost exactly what Theo does in his tutorial using the SSG helper for profile pages, but due to updated Clerk middleware I had to change my trpc.ts file. I have my trpc.ts file set up identical to this: https://github.com/perkinsjr/t3-app-clerk-minimal/blob/main/src/server/api/trpc.ts There is a comment in there that says:
/**
* This helper generates the "internals" for a tRPC context. If you need to use
* it, you can export it from here
*
* Examples of things you may need it for:
* - testing, so we dont have to mock Next.js' req/res
* - trpc's `createSSGHelpers` where we don't have req/res
* @see https://create.t3.gg/en/usage/trpc#-servertrpccontextts
*/
/**
* This helper generates the "internals" for a tRPC context. If you need to use
* it, you can export it from here
*
* Examples of things you may need it for:
* - testing, so we dont have to mock Next.js' req/res
* - trpc's `createSSGHelpers` where we don't have req/res
* @see https://create.t3.gg/en/usage/trpc#-servertrpccontextts
*/
But I can't figure out how to use the "auth" object in the context when defining the SSG helper, it's always erroring when I try to set it up:
import { createServerSideHelpers } from "@trpc/react-query/server";
import { appRouter } from "~/server/api/root";
import { prisma } from "~/server/db";
import superjson from "superjson";


export const generateSSGHelper = () =>
createServerSideHelpers({
router: appRouter,
ctx: { auth, prisma }, // auth errors here saying: No value exists in scope for the shorthand property 'auth'. Either declare one or provide an initializer.ts(18004)
transformer: superjson,
});
import { createServerSideHelpers } from "@trpc/react-query/server";
import { appRouter } from "~/server/api/root";
import { prisma } from "~/server/db";
import superjson from "superjson";


export const generateSSGHelper = () =>
createServerSideHelpers({
router: appRouter,
ctx: { auth, prisma }, // auth errors here saying: No value exists in scope for the shorthand property 'auth'. Either declare one or provide an initializer.ts(18004)
transformer: superjson,
});
3 Replies
aditya
aditya16mo ago
have you tried not passing anything in place of auth because in nextauth version of SSGHelper works with session=null
zendev
zendevOP16mo ago
Tried this, no luck because auth is required in ctx
arete
arete16mo ago
any update on this?
Want results from more Discord servers?
Add your server