T
TanStack2w ago
genetic-orange

Error: createServerOnlyFn() functions can only be called on the server! (After RC)

I am getting this error after the new RC: db.ts:10 Uncaught (in promise) Error: createServerOnlyFn() functions can only be called on the server! at getDatabase (db.ts:10:18) at db.ts:14:19 getDatabase @ db.ts:10 (anonymous) @ db.ts:14 import * as schema from "@/db/schema" import { Pool } from "@neondatabase/serverless" import { createServerOnlyFn } from "@tanstack/react-start" import { drizzle } from "drizzle-orm/neon-serverless" import { serverEnv } from "@/lib/env" // Primary database connection const driver = new Pool({ connectionString: serverEnv.DATABASE_URL }) const getDatabase = createServerOnlyFn(() => drizzle({ client: driver, schema, casing: "snake_case" }) ) export const db = getDatabase()
4 Replies
sensitive-blue
sensitive-blue2w ago
Simply put: it leaks to the client
genetic-orange
genetic-orangeOP2w ago
Yeah i see this on the network tab, everything seems to be leaking to the client -.- This happend after RC release
sensitive-blue
sensitive-blue2w ago
I think you should create a reproducer and open a github issue on the repository
xenial-black
xenial-black2w ago
Execution Model | TanStack Start React Docs
Understanding where code runs is fundamental to building TanStack Start applications. This guide explains TanStack Start's execution model and how to control where your code executes. Core Principle:...
No description

Did you find this page helpful?