tRPCttRPC
Powered by
xdxd#5555 / hanyaX
tRPC•3y ago•
3 replies
xdxd#5555 / hanya

Adding clerk auth object to createServerSideHelpers

So I followed clerk's docs for TRPC (https://clerk.com/docs/nextjs/trpc) and I added
auth
auth
to the
context
context
object. This works great for most requests I've made, but I'm having trouble now that I'm trying to use
getStaticProps
getStaticProps
and
createServerSideHelpers
createServerSideHelpers
.

I slightly changed the
AuthContext
AuthContext
type so that
auth
auth
can be
undefined
undefined
, which would make sense when the page is generated at build. But is there a way to get auth info in there, when the page gets regenerated later as a user visits? Or would I need to make any auth-related stuff part of the client code?

Snippet:
export const getStaticProps: GetStaticProps = async (context) => {
  const helpers = createServerSideHelpers({
    router: appRouter,
    ctx: { prisma, auth: undefined }, // would like to define auth if possible!
    transformer: superjson,
  });
...
export const getStaticProps: GetStaticProps = async (context) => {
  const helpers = createServerSideHelpers({
    router: appRouter,
    ctx: { prisma, auth: undefined }, // would like to define auth if possible!
    transformer: superjson,
  });
...
TRPC | Clerk
Learn how to integrate Clerk into your Next.js with TRPC
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Type of createServerSideHelpers?
nehalistNnehalist / ❓-help
3y ago
SSG helper w/ Clerk not recognizing "auth"
Answer OverflowAAnswer Overflow / ❓-help
3y ago
Issue with trpc fetch when trying to pass Clerk auth to context
entropyEentropy / ❓-help
3y ago