Tribe
Tribe
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Tribe on 1/28/2024 in #questions
TRPC RSC calls forced to use no_store
Curious what the take is over here on having to flag every TRPC api call made server side with no_store, in order to avoid build errors from the next compiler? I tried bringing this up over on the Next Discord since it feels more like an issue that Next should not be throwing an error. And having to use no_store in every RSC with a serevr side api call feels like a bit of an anti pattern. But they kind os suggested this was more of an issue with t3 or TRPC, which I an leaning towards disagreeing with. Thoughts on this or recommended work arounds?
4 replies
TTCTheo's Typesafe Cult
Created by Tribe on 1/10/2024 in #questions
Base t3 app throwing: Dynamic Server error on build
Noticed I was getting a Dynamic server error on a recent t3 app using postgress with Drizzle and I realized simply changing out the Drizzle client (and config) causes the build process to throw a Dynamic server usage error on build. Placing cookies() in the default RSC that comes with T3 seems to cause the error to go away, but that feels like a bit of a hack. Is this also something that occurs with the planetscale setup or is there something wrong with my Drizzle client? Update: I just actually created a planetscale account to test out default settings and it appears the error gets thrown with default planetscale/drizzle as well. Is this a known issue or are there any workarounds? Thanks Drizzle client
import { drizzle } from "drizzle-orm/postgres-js";

import { env } from "~/env";
import * as schema from "./schema";
import postgres from "postgres"

const client = postgres(env.DATABASE_URL)

export type Drizzle = typeof db
export const db = drizzle(client, { schema });
import { drizzle } from "drizzle-orm/postgres-js";

import { env } from "~/env";
import * as schema from "./schema";
import postgres from "postgres"

const client = postgres(env.DATABASE_URL)

export type Drizzle = typeof db
export const db = drizzle(client, { schema });
Drizzle config
import { type Config } from "drizzle-kit";

import { env } from "~/env";

export default {
schema: "./src/server/db/schema.ts",
driver: "pg",
dbCredentials: {
connectionString: env.DATABASE_URL,
},
tablesFilter: ["debug_*"],
} satisfies Config;
import { type Config } from "drizzle-kit";

import { env } from "~/env";

export default {
schema: "./src/server/db/schema.ts",
driver: "pg",
dbCredentials: {
connectionString: env.DATABASE_URL,
},
tablesFilter: ["debug_*"],
} satisfies Config;
9 replies
TTCTheo's Typesafe Cult
Created by Tribe on 12/25/2023 in #questions
Adding Supabase to TRPC context
I am using Supabase for auth and db in a create t3 app project and I was curious if this would be the correct way to get the user session data into the trcp context. I modified the createTRCPContext method to this... server/api/trpc.ts
import { cookies } from 'next/headers'
import { createRouteHandlerClient } from "@supabase/auth-helpers-nextjs"
import type * as schema from "../db/schema";

export const createTRPCContext = async (opts: { headers: Headers }) => {
const cookieStore = cookies()

const supabase = createRouteHandlerClient<typeof schema>({
cookies: () => cookieStore,
})

const session = await supabase.auth.getSession()

return {
db,
session,
...opts,
};
};
import { cookies } from 'next/headers'
import { createRouteHandlerClient } from "@supabase/auth-helpers-nextjs"
import type * as schema from "../db/schema";

export const createTRPCContext = async (opts: { headers: Headers }) => {
const cookieStore = cookies()

const supabase = createRouteHandlerClient<typeof schema>({
cookies: () => cookieStore,
})

const session = await supabase.auth.getSession()

return {
db,
session,
...opts,
};
};
or alternatively is it actually possible to just create a supabaseServerClient / createRouteHandlerClient within the TRCP procedures themselves whenever I need access to the session data?
11 replies