Ensure server-only code remains server-only
having a bit of trouble understanding how "server only" code stays "server only" in TSS. i assume this dynamic import is an anti pattern:
i'm not sure how i'd use that function in a
beforeLoad
otherwise, eg
any help is much appreciated!3 Replies
extended-salmonOP•7mo ago
for context
@/lib/server/auth
imports postgres. that is causing the client to crash, of courserising-crimson•7mo ago
you need to use createServerFn to isolate the code
xenial-black•7mo ago
loaders are isomorphic so you'd have to wrap listOrganizations in a server function
https://tanstack.com/start/latest/docs/framework/react/server-functions
Server Functions | TanStack Start React Docs
What are Server Functions? Server functions allow you to specify logic that can be invoked almost anywhere (even the client), but run only on the server. In fact, they are not so different from an API...