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()
5 Replies
eastern-cyan•3mo ago
Simply put: it leaks to the client
genetic-orangeOP•3mo ago
Yeah i see this on the network tab, everything seems to be leaking to the client -.- This happend after RC release
eastern-cyan•3mo ago
I think you should create a reproducer and open a github issue on the repository
genetic-orange•3mo 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:...

grumpy-cyan•4w ago
Hi @Kevin Ris . Did you manage to solve this issue? Facing the same issue recently